Monday, 21 October 2019

Specifying marker size in data unit for plotly

I switched from matplotlib to plotly mainly to plot smooth animations in 2D/3D. I want to plot the motion of robots consisting of multiple circles/spheres.

The different body parts of the robot have different sizes and the circles need to represent that accurately. The question is if there is a way in plotly to specify the size of the markers in data units.

In matplotlib I know two alternatives. One is to use patches (matplotlib.patches.Circle). The second option is to scale the marker_size correctly by taking the dpi into account (See related question for matplotlib).

So is it possible to animate shapes in plotly (3D)? Or is there a way to specify the size of the markers in data units or scale the sizeref attribute correctly?

# Point with radius 2 (approx.)
from plotly.offline import plot
import plotly.graph_objs as go

trace = go.Scatter(x=[4], y=[4],
                   mode='markers',
                   marker={'size': 260, 'sizeref': 1})

layout = dict(yaxis=dict(range=[0, 10]),
              xaxis=dict(range=[0, 10]))

fig = dict(data=[trace], layout=layout)
plot(fig, image_height=1000, image_width=1000)


from Specifying marker size in data unit for plotly

No comments:

Post a Comment