Skip to content
Related Articles

Related Articles

3D Cone Plots using Plotly in Python
  • Last Updated : 10 Jul, 2020

Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.

3D Cone Plot in Plotly

In plotly, a cone plot is a plot that has 3d equivalent of a 2D quiver plot. A 3d vector represents the direction and norm of the vectors.

  • 3d coordinates are X, Y, and Z which define the coordinates for a vector.
  • 3d coordinates of a vector field are  U, V, and W which is defined as the vector field.

Syntax: plotly.graph_objects.Cone(arg=None, anchor=None, autocolorscale=None, cauto=None, cmax=None, cmid=None, cmin=None, coloraxis=None, colorbar=None, colorscale=None, customdata=None, customdatasrc=None, hoverinfo=None, hoverinfosrc=None, hoverlabel=None, hovertemplate=None, hovertemplatesrc=None, hovertext=None, hovertextsrc=None, ids=None, idssrc=None, legendgroup=None, lighting=None, lightposition=None, meta=None, metasrc=None, name=None, opacity=None, reversescale=None, scene=None, showlegend=None, showscale=None, sizemode=None, sizeref=None, stream=None, text=None, textsrc=None, u=None, uid=None, uirevision=None, usrc=None, v=None, visible=None, vsrc=None, w=None, wsrc=None, x=None, xsrc=None, y=None, ysrc=None, z=None, zsrc=None, **kwargs)

Parameters:

u – Sets the x components of the vector field.



v – Sets the y components of the vector field.

w – Sets the z components of the vector field.

x – Sets the x coordinates of the vector field and of the displayed cones.

y – Sets the y coordinates of the vector field and of the displayed cones.

z – Sets the z coordinates of the vector field and of the displayed cones.

Example:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Cone(x=[3],
                             y=[1],
                             z=[4],
                             u=[1],
                             v=[7],
                             w=[2]))
  
fig.show()

chevron_right


Output:



Plotting Multiple 3D Cones

In plotly, the multiple 3d cones use the parameter scene, in this the graph show many cones in a single graph that help to differentiate between each other. It can be created by passing multiple values in the x, y, z, u, v, w parameters.

Example 1:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Cone(x=[1,3], 
                             y=[1,3],
                             z=[1,4],
                             u=[1,6],
                             v=[1,7],
                             w=[0,2]))
  
fig.show()

chevron_right


Output:

Example 2:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

import plotly.graph_objects as go
  
fig = go.Figure(data=go.Cone(x=[11,31, 12], 
                             y=[12,32, 21],
                             z=[13,41, 15],
                             u=[14,16, 17],
                             v=[15,27, 10],
                             w=[10,29, 21]))
  
fig.show()

chevron_right


Output:


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :