Questions tagged [legend]
A graph legend is commonly used when plotting several sets of data within the same diagram. The legend associates each plot with its corresponding data.
legend
5,167
questions
61
votes
4
answers
106k
views
Is it possible to add a string as a legend item
I am producing some plots in matplotlib and would like to add explanatory text for some of the data. I want to have a string inside my legend as a separate legend item above the '0-10' item. Does ...
59
votes
7
answers
80k
views
Which CSS tag creates a box like this with title?
I want to create a box like this with title:
Can any one please let me know if there is a default CSS tag to do this? Or do I need to create my custom style?
58
votes
1
answer
47k
views
ggplot2 legend items in a single horizontal row
It seems that the code I wrote and tested last week has now suddenly decided to change the output even though nothing in the code or the version of R or Rstudio has changed.
Previously when I drew a ...
57
votes
3
answers
93k
views
How to change the legend edgecolor and facecolor
Is there while rcParams['legend.frameon'] = 'False' a simple way to fill the legend area background with a given colour. More specifically I would like the grid not to be seen on the legend area ...
56
votes
7
answers
200k
views
No handles with labels found to put in legend
I'm trying to create a parallelogram in PyPlot. I'm not up to drawing the parallelogram--first I'm putting in the vector arrows--using the following code:
fig = plt.figure()
ax = fig.add_subplot(111)
...
56
votes
4
answers
81k
views
Matplotlib savefig with a legend outside the plot
Reading the following article, I managed to put a legend outside plot.
How to put the legend out of the plot
code:
import matplotlib.pyplot as pyplot
x = [0, 1, 2, 3, 4]
y = [xx*xx for xx in x]
...
55
votes
5
answers
117k
views
Manually set color of points in legend
I'm making a scatter plot which looks like this:
(MWE at bottom of question)
As can be seen in the image above the colors of the points in the legend are set to blue automatically by matplotlib. I ...
54
votes
5
answers
75k
views
How to change the text color of font in legend?
Is there a way to change the font color of the legend in a matplotlib plot?
Specially in occasions where the background of the plot is dark, the default black text in the legend is hard or impossible ...
54
votes
6
answers
92k
views
How to edit legend labels in google spreadsheet plots?
I'm trying to plot some data in Google spreadsheet:
And as you may see all of the series are in a same column and I can't use the any of the rows as headers. My plot looks like this:
I would ...
52
votes
2
answers
56k
views
change both legend titles in a ggplot with two legends
I have two legends on my ggplot with two different legend titles (automatically created from ggplot()). Now, I want to change this legend titles. + labs(colour = "legend name") only change the second ...
51
votes
3
answers
106k
views
Unable to show legend in seaborn distplot
I am new to plotting in python and trying following code to plot distribution in seaborn but unable to see the legend, i.e., test_label1 and test_label1 on the plot.
import matplotlib.pylab as plt
...
50
votes
2
answers
55k
views
How to make custom legend
I currently generate my legend with matplotlib this way:
if t==25:
l1,l2 = ax2.plot(x320,vTemp320,'or',x320,vAnaTemp320,'-r')
elif t==50:
l3,l4 = ax2.plot(x320,vTemp320,'ob',x320,vAnaTemp320,'-...
48
votes
1
answer
101k
views
Legend overlaps with the pie chart
Using matplotlib in python. The legend overlaps with my pie chart. Tried various options for "loc" such as "best" ,1,2,3... but to no avail. Any Suggestions as to how to either exactly mention the ...
47
votes
5
answers
35k
views
Is it possible in chartjs to hide certain dataset legends?
Is it possible to only hide certain dataset legends in chartjs? I know it is possible to hide all with
options: {
legend: {
display: false
46
votes
5
answers
86k
views
How do you create a legend for a contour plot?
I can't seem to find the answer anywhere! I found a discussion here, but trying this I get a TypeError: 'NoneType' object is not iterable:
>>> import numpy as np
>>> import ...