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,165
questions
1661
votes
18
answers
1.9m
views
How to put the legend outside the plot
I have a series of 20 plots (not subplots) to be made in a single figure. I want the legend to be outside of the box. At the same time, I do not want to change the axes, as the size of the figure gets ...
519
votes
9
answers
1.0m
views
How to change legend fontsize with matplotlib.pyplot
Simple question here: I'm trying to get the size of my legend using matplotlib.pyplot to be smaller (i.e., the text to be smaller). The code I'm using goes something like this:
plot.figure()
plot....
508
votes
7
answers
1.4m
views
Adding a matplotlib legend
How can one create a legend for a line graph in Matplotlib's PyPlot without creating any extra variables?
Please consider the graphing script below:
if __name__ == '__main__':
PyPlot.plot(length, ...
481
votes
11
answers
481k
views
Secondary axis with twinx(): how to add to legend
I have a plot with two y-axes, using twinx(). I also give labels to the lines, and want to show them with legend(), but I only succeed to get the labels of one axis in the legend:
import numpy as np
...
376
votes
4
answers
604k
views
Remove legend ggplot 2.2
I'm trying to keep the legend of one layer (smooth) and remove the legend of the other (point). I have tried shutting off the legends with guides(colour = FALSE) and geom_point(aes(color = vs), show....
337
votes
10
answers
378k
views
How do I make a single legend for many subplots?
I am plotting the same type of information, but for different countries, with multiple subplots with Matplotlib. That is, I have nine plots on a 3x3 grid, all with the same for lines (of course, ...
330
votes
11
answers
444k
views
Remove the legend on a matplotlib figure
To add a legend to a matplotlib plot, one simply runs legend().
How to remove a legend from a plot?
(The closest I came to this is to run legend([]) in order to empty the legend from data. But that ...
298
votes
7
answers
254k
views
Moving matplotlib legend outside of the axis makes it cutoff by the figure box
I'm familiar with the following questions:
Matplotlib savefig with a legend outside the plot
How to put the legend out of the plot
It seems that the answers in these questions have the luxury of ...
222
votes
11
answers
452k
views
Plot a legend outside of the plotting area in base graphics?
As the title says: How can I plot a legend outside the plotting area when using base graphics?
I thought about fiddling around with layout and produce an empty plot to only contain the legend, but I ...
212
votes
9
answers
271k
views
Add a common Legend for combined ggplots
I have two ggplots which I align horizontally with grid.arrange. I have looked through a lot of forum posts, but everything I try seem to be commands that are now updated and named something else.
...
200
votes
8
answers
73k
views
Remove 'a' from legend when using aesthetics and geom_text
How can I can remove the letter 'a' from the legend generated by this code? If I remove the geom_text, then the 'a' letter will not show in the legend. I want to keep geom_text, though.
ggplot(data = ...
187
votes
9
answers
194k
views
Is there a way to change the spacing between legend items in ggplot2?
Is there a way to change the spacing between legend items in ggplot2? I currently have
legend.position ="top"
which automatically produces a horizontal legend. However, the spacing of the items is ...
184
votes
4
answers
406k
views
Add legend to ggplot2 line plot
I have a question about legends in ggplot2. I managed to plot three lines in the same graph and want to add a legend with the three colors used. This is the code used
library(ggplot2)
## edit from ...
173
votes
5
answers
239k
views
How to manually create a legend
I am using matplotlib and I would like to manually add items to the legend that are a color and a label. I am adding data to to the plot to specifying there would lead to a lot of duplicates.
My ...
173
votes
4
answers
187k
views
Global legend and title aside subplots
I've started with matplot and managed some basic plots, but now I find it hard to discover how to do some stuff I need now :(
My actual question is how to place a global title and global legend on a ...