Skip to main content

All Questions

Tagged with
33 votes
3 answers
49k views

Customizing the order of legends in plotly

I am trying to customize the order of legends while plotting stacked bar plots in plotly,python. data = [ go.Bar( y=df['sid'], # assign x as the dataframe column 'x' ...
Natasha's user avatar
  • 1,431
2 votes
1 answer
427 views

How to create two legend objects for a single plot instance?

I use the following example code to generate a bar plot. import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 5, 5) y = np.exp(x) w = x[1] - x[0] colors = ['blue' if idx % 2 == 0 ...
user avatar
6 votes
1 answer
3k views

Centering matplotlib legend entries within incomplete/unfilled rows?

Say I'm making a plot with five items, and only have room to create a legend with 3 columns (more columns than this would be too wide), e.g. import matplotlib.pyplot as plt fig, ax = plt.subplots() ...
Luke Davis's user avatar
  • 2,606
4 votes
3 answers
244 views

Using a miniature version of the plotted data as the legend handle in python

Is there any way to use the line plotted in a figure in matplotlib as the handle in the legend? I'm thinking for example in this basic code rather than a straight line in the legend have a small ...
slekce's user avatar
  • 43
3 votes
3 answers
8k views

bokeh add legend to Step graph

How can I add a legend to lines in Step graph example for bokeh: https://docs.bokeh.org/en/latest/docs/reference/models/glyphs/step.html I would like to have legend in 'top right' corner of plot for ...
Admed's user avatar
  • 71
2 votes
2 answers
1k views

How to create a basic legend to a multicolored line?

I am currently finishing a bigger project and the last part is to add a simple legend to a plot of a multicolored line. The line only contains two different colors. The following image shows the plot ...
zorrolo's user avatar
  • 117
1 vote
1 answer
1k views

Plotly - clicking on legend items - how to make an initial setting?

When someone clicks on a legend item, it becomes grey, and the data disappears, for instance, here. It is possible to set that an item from a legend will be grey after opening the .HTML output and ...
Elena Greg's user avatar
  • 1,125