Skip to content

Carpet plots: showlegend not working #1540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pfbuxton opened this issue Apr 30, 2019 · 2 comments
Closed

Carpet plots: showlegend not working #1540

pfbuxton opened this issue Apr 30, 2019 · 2 comments

Comments

@pfbuxton
Copy link

pfbuxton commented Apr 30, 2019

In this example the showlegend does not cause a legend to show.

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go

app = dash.Dash(__name__)

traces = []
traces.append(go.Carpet(
    a = [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6],
    b = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
    y = [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10],
    name='test',
    showlegend=True
))

layout = []

app.layout = html.Div(children=[
    html.H1(children='showlegend within Carpet not showing'),
    
    html.Div([
        dcc.Graph(
            id='Recon_plasma_image',
            config=dict( displayModeBar=False ),
            figure=dict( data=traces, layout=layout )
        )
    ], style={ 'width':'500px', 'height':'600px' }),
])

if __name__ == '__main__':
    app.run_server(debug=True)

Also in this example legendgroup does not seem to work either.

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go

app = dash.Dash(__name__)

traces = []
traces.append(go.Carpet(
    a = [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6],
    b = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
    y = [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10],
    name='test',
    showlegend=False,
    carpet='c1',
    legendgroup='group1',
))
traces.append(go.Scatter(
    x=[0.1, 0.2],
    y=[1, 2],
    showlegend=False,
    legendgroup='group1',
    mode='lines',
    line=dict( color='black', dash='solid' ),
))
traces.append(go.Scatter(
    x=[1, 2],
    y=[1, 2],
    showlegend=True,
    name='group1 name',
    legendgroup='group1',
    mode='lines',
    line=dict( color='black', dash='solid' ),
))

layout = []

app.layout = html.Div(children=[
    html.H1(children='legendgroup not working with the Carpet plot'),
    
    html.Div([
        dcc.Graph(
            id='Recon_plasma_image',
            config=dict( displayModeBar=False ),
            figure=dict( data=traces, layout=layout )
        )
    ], style={ 'width':'500px', 'height':'600px' }),
])

if __name__ == '__main__':
    app.run_server(debug=True)

Have I understood this correctly and should showlegend and legendgroup do what I thought?

Thanks,
Peter

@jonmmease
Copy link
Contributor

Hi @pfbuxton,

Carpet traces don't support legend entries unfortunately. Prior to plotly.py version 3.8 the showlegend and legendgroup properties were included in every trace, including those that don't support legends. This was cleaned up in version 3.8 and there is not a validation error raised what these properties are provided to traces that don't support legends.

Feel free to open a feature request in the Plotly.js project (https://github.com/plotly/plotly.js/issues) for carpet legend support.

@pfbuxton
Copy link
Author

pfbuxton commented May 2, 2019

Feature requested on Plotly.js:
plotly/plotly.js#3828

@pfbuxton pfbuxton closed this as completed May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants