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
18 votes
1 answer
29k views

Sharing same legends for subplots in plotly

I've two plots created in the same figure using subplots in plotly. import plotly.graph_objects as go import numpy as np import pandas as pd from plotly.subplots import make_subplots df = pd....
Natasha's user avatar
  • 1,431
17 votes
1 answer
27k views

add a line to matplotlib subplots

I would like to do a subplot of two figures with matplotlib and add a horizontal line in both. This is probably basic, but I don't know how to specify that one of the lines should be drawn in the ...
mfastudillo's user avatar
  • 1,586
10 votes
2 answers
31k views

How to position legends inside a plot in Plotly

I have got this code from Plotly page. I need to make the background transparent and the axis highlighted. And also the legends positioned inside the plot. import plotly.graph_objects as go fig = go....
Leolime's user avatar
  • 317
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
5 votes
1 answer
6k views

How do I show legend for different colors in bokeh scatter plot?

This is my plot. I need to show the legend for the different colors used. How do I do that? My code for the plot: def mscatter(p, x, y, c,typestr,source): p.scatter(x, y, marker=typestr, ...
n00b's user avatar
  • 1,599
4 votes
2 answers
3k views

How to input dictionary kwargs into matplotlib legend routine?

I would like to write a function that accepts a dictionary of legend parameters before outputting a plot. I've included a small example below. Imports import numpy as np import matplotlib.pyplot as ...
user avatar
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
4 votes
2 answers
6k views

How to add a legend entry without a symbol/color into an existing legend?

I have a plot with a legend. I would like to add an entry into the legend box. This entry could be something like a fit parameter or something else descriptive of the data. As an example, one can ...
user avatar
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
3 votes
1 answer
4k views

Suppress WARNING:matplotlib.legend:No handles with labels found to put in legend

Sorry if this has been asked before but all the answers I found didn't work for me. I'm looking for a way to suppress this warning. The context is that I wrote a function that creates a lot of plots ...
rhedak's user avatar
  • 409
3 votes
0 answers
8k views

Python- Change legend position in plot [duplicate]

I want to change legend position because legend names a little bit longer(X Position according to ...) so that I want to put this name vertical (right side of graph or under the plot). I have three ...
Ugur's user avatar
  • 111
2 votes
3 answers
1k views

Python matplolib legend how to reduce distance between frame left edge and markers

As question suggests, I'm trying to reduce the distance between the left edge of the legend frame and the markers. In figure there is the current plot. I would like to find a way to: keeping the ...
Giuseppe Angora's user avatar
2 votes
2 answers
3k views

Matplotlib: adding legend for each column of numpy array

Hi I have a numpy array a = np.random.uniform(0,1, size = (10,3)) I want to plot each of the columns with its own label plt.plot(a, label = ['label1', 'label2', 'label3']) plt.legend() How can I ...
Euler_Salter's user avatar
  • 3,489
2 votes
1 answer
136 views

How to plot the legend of this graph of which there are many functions?

I have a matrix X contains only 1 row that serves as an input. I have a matrix Y of which each row serves as an output of a function. If Y has 5 rows, then we have 5 different functions. I plot all ...
Akira's user avatar
  • 2,780

15 30 50 per page
1
2 3 4 5
7