Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Is it possible to use `hv` line shape in a Scattergl plot?

The documentation explains how to use different line shapes/interpolation in scatter plots:

newplot

I would like to use the same feature, using go.Scattergl instead of go.Scatter. The code used is:

import plotly.plotly as py
import plotly.graph_objs as go

trace1 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[1, 3, 2, 3, 1],
    mode='lines+markers',
    name="'linear'",
    hoverinfo='name',
    line=dict(
        shape='linear'
    )
)
trace2 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[6, 8, 7, 8, 6],
    mode='lines+markers',
    name="'spline'",
    text=["tweak line smoothness<br>with 'smoothing' in line object"],
    hoverinfo='text+name',
    line=dict(
        shape='spline'
    )
)
trace3 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[11, 13, 12, 13, 11],
    mode='lines+markers',
    name="'vhv'",
    hoverinfo='name',
    line=dict(
        shape='vhv'
    )
)
trace4 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[16, 18, 17, 18, 16],
    mode='lines+markers',
    name="'hvh'",
    hoverinfo='name',
    line=dict(
        shape='hvh'
    )
)
trace5 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[21, 23, 22, 23, 21],
    mode='lines+markers',
    name="'vh'",
    hoverinfo='name',
    line=dict(
        shape='vh'
    )
)
trace6 = go.Scattergl(
    x=[1, 2, 3, 4, 5],
    y=[26, 28, 27, 28, 26],
    mode='lines+markers',
    name="'hv'",
    hoverinfo='name',
    line=dict(
        shape='hv'
    )
)
data = [trace1, trace2, trace3, trace4, trace5, trace6]
layout = dict(
    legend=dict(
        y=0.5,
        traceorder='reversed',
        font=dict(
            size=16
        )
    )
)
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='line-shapes')

However, when run, the code above return an error, saying that

ValueError: Invalid property specified for object of type plotly.graph_objs.scattergl.Line: ‘shape’

Valid properties:
    color
        Sets the line color.
    dash
        Sets the style of the lines.
    width
        Sets the line width (in px).

Question: Is this because Scattergl does not support this feature yet? Is not intended to support this feature in the future? Or is it just due to an outdated install on my side?

Hi @ebosi,

Unfortunately, the scattergl trace doesn’t support line shapes at this point. It’s possible it could in the future, but I’m not aware of any plans for it at this point.

-Jon

Thank you for the answer!

Hi @ebosi,

As it turns out, this was just implemented and released in plotly.js 1.42.0 (https://github.com/plotly/plotly.js/pull/3087). This will be included in plotly.py 3.4.0 (hopefully to be released in the next week or so).

-Jon

1 Like

Brilliant! Thanks for the follow up!