![]() ![]() ![]() Cone ( x = x, y = y, z = z, u = u, v = v, w = w, colorscale = "Blues", name = 'cones' )) fig. ravel (), isomin = 1.9, isomax = 1.9, colorscale = "BuGn", name = 'isosurface' )) fig. Import numpy as np import aph_objects as go # Define vector and scalar fields x, y, z = np. update_layout ( legend = dict ( groupclick = "toggleitem" )) fig. update_layout ( title = "Try Clicking on the Legend Items!" ) fig. Scatter ( x =, y =, legendgroup = "group2", name = "second legend group - average", mode = "lines", line = dict ( color = "MediumPurple" ) )) fig. Scatter ( x =, y =, legendgroup = "group2", legendgrouptitle_text = "Second Group Title", name = "second legend group", mode = "markers", marker = dict ( color = "MediumPurple", size = 10 ) )) fig. Scatter ( x =, y =, legendgroup = "group", name = "first legend group - average", mode = "lines", line = dict ( color = "Crimson" ) )) fig. Scatter ( x =, y =, legendgroup = "group", # this can be any string, not just "group" legendgrouptitle_text = "First Group Title", name = "first legend group", mode = "markers", marker = dict ( color = "Crimson", size = 10 ) )) fig. Scatter ( x =, y =, legendgroup = "group2", name = "second legend group - average", mode = "lines", line = dict ( color = "MediumPurple" ), showlegend = False )) fig. Scatter ( x =, y =, legendgroup = "group2", name = "second legend group", mode = "markers", marker = dict ( color = "MediumPurple", size = 10 ) )) fig. Scatter ( x =, y =, legendgroup = "group", name = "first legend group - average", mode = "lines", line = dict ( color = "Crimson" ), showlegend = False, )) fig. Scatter ( x =, y =, legendgroup = "group", # this can be any string, not just "group" name = "first legend group", mode = "markers", marker = dict ( color = "Crimson", size = 10 ) )) fig. ![]() Alternatively, color axes can be configured within the trace itself. Color axes have a legend-like component called color bars. Multiple traces can be linked to the same color axis. Traces which support continuous color can also be associated with color axes in the layout via the coloraxis attribute. Plotly Express has robust support for discrete color to make this easy. The fact that legend items are linked to traces means that when using discrete color, a figure must have one trace per color in order to get a meaningful legend. Traces that support legend items also support the legendgroup attribute, and all traces with the same legend group are treated the same way during click/double-click interactions. Users may show or hide traces by clicking or double-clicking on their associated legend item. ![]() Traces which are their own subplots (see above) do not support this, with the exception of traces of type pie and funnelarea for which every distinct color represented in the trace gets a separate legend item. Whether or not a given trace appears in the legend is controlled via the showlegend attribute. Traces of most types can be optionally associated with a single legend item in the legend. ![]()
0 Comments
Leave a Reply. |