Skip to main content

All Questions

Tagged with
1 vote
0 answers
39 views

Text shifted in legend because of LaTeX formatting in matplotlib

For some reason in my subplot, the legend of the second ax is cropped at the bottom inside of the legend box. It seems the index causes the text to shift a bit. The legend box itself is perfectly fine....
Chris Ze Third's user avatar
0 votes
1 answer
29 views

custom legend function for matplotlib chart

Right now when I have dual y-axis and I want to have one legend box for both of my labels I do the following: fig, ax = plt.subplots(1,2) ax0=ax[0].twinx() line1=ax[0].plot([1, 2, 3], [4, 5, 6], 'b', ...
user20856754's user avatar
0 votes
0 answers
34 views

Matplotlib legend position for graphs

x = ['TPhP', 'TPrP', 'THP', 'OEP', 'Aristophyll A', 'TETMP', 'DMDHP', 'THDPP', 'BDTDP'] plt.xticks(range(len(x)), x, rotation='vertical') plt.ylim([-6, 12]) y1 = [-3.8681, -3.7851, -3.6178, -3....
Sivanujan Suthaharan's user avatar
0 votes
1 answer
58 views

How to have a figure legend and a subplot legend

I would like to plot some data in subplots and I would like to have a legend for the overall figure but also a legend for one of the subplots, where the labels of the subplot should not appear in the ...
hwerner's user avatar
  • 49
2 votes
1 answer
486 views

How to create a custom color legend for a calendar-based heatmap plot (calmap)?

I have a dataframe that contains numerical data collected over the whole year, which I want to plot as a heatmap over time (similar to Github contributions), where months are plotted along the x-axis ...
pinguino's user avatar
0 votes
1 answer
91 views

Why is there multiple indentical entries in a legend when plotting with matplotlib? [duplicate]

I try to plot a list a of values with respect to time and I have two examples: one where Im plotting angular velocities and the other where Im plotting linear accelerations. For both graphs the code ...
SvylantisCPU's user avatar
0 votes
1 answer
175 views

Adjust spacing between 2 markers of same line displayed in the legend of matplotlib plot

I am plotting 2 markers of the same line using the following code and I want to adjust the spacing between two markers in the legend. Code : ref. import matplotlib.pyplot as plt from matplotlib....
Natasha's user avatar
  • 1,431
1 vote
2 answers
335 views

create legend for markercolor and size

I've created the following figure: With following code: matplotlib.rcParams.update({'font.size': 10}) fig = plt.figure(figsize=(16, 9), dpi=300, facecolor='white') ax = plt.subplot(111, projection=...
Dante van der Heijden's user avatar
-1 votes
1 answer
367 views

Use variables in legend handles

I want to graph multiple different bar charts and the colors in each graph will vary depending on the data being plotted. I would like to have a legend with handles (to accompany each set of data and ...
Eric Q's user avatar
  • 19
0 votes
0 answers
120 views

Getting a TypeError: cannot unpack non-iterable PathCollection object. How to plot labels of different axis for bar chart and scatter in one legend?

I am receiving a TypeError: cannot unpack non-iterable PathCollection object. I am trying to make a legend below the center of my graph for two axis. My combination plot is one bar chart and two ...
NenEnd13's user avatar
0 votes
1 answer
194 views

How to remove duplicates and move the legend list to outside of the graph concurrently?

I have seen many good questions questions and answers, but I am not sure how to combine two of them: How to put the legend outside the plot Duplicate items in legend in matplotlib? These two ...
DialFrost's user avatar
  • 1,709
0 votes
2 answers
159 views

How do I move a legend label within its own legend in matplotlib?

I have a graph with, say, three lines. The red and blue lines have short labels, and the black dotted line has a longer more detailed label. Currently I have some code to produce the figure below. ...
Garf's user avatar
  • 101
0 votes
1 answer
157 views

Lineplot - plot a single legend for uneven number of subplots

I'm working on the following graph where I'd like to plot is single legend that applies to all, essentially this would be a small box where blue color line is AB=0 and green line is AB = 1. Moreover, ...
Geosphere's user avatar
  • 355
0 votes
1 answer
441 views

Format of legend with equation in matplotlib

How do we show an equation in the legend of a pyplot plot? Sample code below: fig = plt.figure(figsize=(5, 3), dpi=my_dpi) ax = fig.add_subplot(111) a = 2.0 b = 3.0 xdata = np.arange(6) ydata = a*np....
Abhinav Kumar's user avatar
1 vote
0 answers
88 views

How to add legend and edit lines in plot?

I'm trying to overlay a legend to this plot but am not sure how to. I want the legend to include the two bar data sets and the two lines. I'd also like, if possible, to extend the dotted lines in the ...
spcs_lay's user avatar

15 30 50 per page
1
2 3 4 5
11