Arrow lines between points, scatter plot using graph_objects

I am trying to build a scatterplot with arrow lines inbetween the two points, denoting the movement from 2019-2021. Looking at the documentation here (Styling markers in Python), the following code should work for graph_objects.

        mode="lines+markers",
        marker=dict(
            symbol="arrow",
            size=15,
            angleref="previous",
        ),

However, when using that code I get the following error.

ValueError:
Invalid value of type ‘builtins.str’ received for the ‘symbol’ property of scatter.marker
Received value: ‘arrow’

Has there been an update since the documentation was published?

1 Like

@plotmaster422 This is the list of available arrow symbols:

arrow_style= ['arrow-up', 
            'arrow-up-open',  'arrow-down',
            'arrow-down-open',  'arrow-left', 
            'arrow-left-open', 'arrow-right', 
            'arrow-right-open',  'arrow-bar-up', 
            'arrow-bar-up-open',  'arrow-bar-down', 
             'arrow-bar-down-open',  'arrow-bar-left',
             'arrow-bar-left-open', 
            'arrow-bar-right',  'arrow-bar-right-open', 'arrow',  'arrow-open',
            'arrow-wide',  'arrow-wide-open']

got it, will try all of those options and see if any work.

@empet is there any way to have the arrow point in the direction of the line? Looks like “angleref” was discontinued.

help(go.scatter.Marker.angleref) displays the following information:

  Sets the reference for marker angle. With "previous", angle 0
    points along the line from the previous point to this one. With
    "up", angle 0 points toward the top of the screen.
    
    The 'angleref' property is an enumeration that may be specified as:
      - One of the following enumeration values:
            ['previous', 'up']

Example (Plotly 5.11.0):

fig = go.Figure(go.Scatter(x=[1,3], y=[4,2],
            marker= dict(size=10,symbol= "arrow-bar-up", angleref="previous")))
fig.update_layout(width=500, height=300)
fig.show()

arrow

4 Likes

Thanks for you responsiveness! When I run this I get the following error:

ValueError: Invalid property specified for object of type plotly.graph_objs.scatter.Marker: ‘angleref’

Did you mean “sizeref”?

Updating this post to say that it looks like “angelref” was added in a recent release.

Updating my Google Colab environment to mirror the latest release. Thanks for your help!

1 Like

same here, just restart the kernel and it should be ok :slight_smile:

2 Likes