plotly

Plotly.Graph_objects.cone

“A cone plot is used to represent a 3d vector field using cones showing the direction and norm of the vector.

Let us discuss how we can create a cone plot using the Plotly graph_objects module.”

Syntax

The syntax for creating a cone plot using the Plotly graph_objects module is as shown below:

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, legendgrouptitle=None,

legendrank=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, uhoverformat=None, uid=None, uirevision=None, usrc=None, v=None,

vhoverformat=None, visible=None, vsrc=None, w=None, whoverformat=None,

wsrc=None, x=None, xhoverformat=None, xsrc=None, y=None, yhoverformat=None,

ysrc=None, z=None, zhoverformat=None, zsrc=None, **kwargs)

The following is the list of the most important parameters you will need to know:

  1. u – defines the x component of the vector.
  2. v – specifies the y component of the vector.
  3. w – sets the z component of the vector.
  4. x – sets the x coordinate of the vector.
  5. y – sets the y coordinate of the vector.
  6. z – sets the z coordinate of the vector.

Example

The following example shows how to create a simple cone plot using the plotly graph_objects.

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

The code above should return a cone plot as shown. Keep in mind you will need to rotate and customize the camera to get the specific view.

Multiple Cones

To create multiple cones, you can specify multiple values in the x,y,z,u,v, and w parameters as shown:

import plotly.graph_objects as go

fig = go.Figure(data=go.Cone(
    x=[1,2,3],
    y=[1,2,3],
    z=[1,2,3],
    u=[1,2,3],
    v=[1,2,3],
    w=[1,2,3]
))
fig.show()

This should return multiple cones with the specified parameters as shown:

Closing

This article illustrates how you can create 3d cones using the plotly graph_objects module.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list