All Questions
Tagged with legend legend-properties
253
questions
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, ...
337
votes
10
answers
377k
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, ...
114
votes
4
answers
149k
views
How to move or position a legend in ggplot2
I'm trying to create a ggplot2 plot with the legend beneath the plot.
The ggplot2 book says on p 112 "The position and justification of legends are controlled by the theme setting legend.position, ...
78
votes
4
answers
138k
views
Change main plot legend label text
So far I have been able to label the subplots just fine but I'm having an issue with the main one.
Here's the relevant part of my code:
data_BS_P = data[channels[0]]
data_BS_R = data[channels[1]]
...
78
votes
9
answers
158k
views
How do I assign multiple legend labels at once?
I have the following dataset:
x = [0, 1, 2, 3, 4]
y = [ [0, 1, 2, 3, 4],
[5, 6, 7, 8, 9],
[9, 8, 7, 6, 5] ]
Now I plot it with:
import matplotlib.pyplot as plt
plt.plot(x, y)
However, ...
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 ...
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 ...
35
votes
1
answer
53k
views
Draw a box around a legend ggplot2
I created a plot with a custom legend in ggplot2. I tried to draw a box around all the items in the legend, however I could only draw a box around each individual item. How can I create only one box ...
35
votes
5
answers
44k
views
How to make two markers share the same label in the legend
What I want is like this:
What I get is this:
So how to merge the markers into one label?
also for the lines, for the lines, of course, u can realize it by not assigning label to the second line ...
33
votes
2
answers
152k
views
Matplotlib automatic legend outside plot [duplicate]
I am trying to use the keyword bbox_to_anchor() in a matplotlib plot in Python.
Here is a very basic plot that I have produced based on this example. :
import matplotlib.pyplot as plt
x = [1,2,3]
...
27
votes
5
answers
80k
views
Two geom_points add a legend
I plot a 2 geom_point graph with the following code:
source("http://www.openintro.org/stat/data/arbuthnot.R")
library(ggplot2)
ggplot() +
geom_point(aes(x = year,y = boys),data=arbuthnot,colour = '#...
26
votes
3
answers
95k
views
How can I control the placement of my Chart.JS pie chart's legend, as well as its appearance?
I am able to create a pie chart using Chart.JS with this code:
HTML
<div>
<canvas id="top10ItemsChart" style="padding-left:20px" width="320" height="320"></canvas>
<div ...
21
votes
4
answers
43k
views
How to change legend fontname in matplotlib
I would like to display a font in Times New Roman in the legend of a matplotlib plot.
I have changed all other tick labels/axis labels/titles to Times New Roman, and have searched the documentation ...
21
votes
1
answer
15k
views
Get ggplot2 legend to display percentage sign in r
Below is a reproducible example of the issue I am trying to solve. I have created a heatmap of sorts in ggplot2 and things have been going well. Since I have put percentage signs on the data to use ...
14
votes
2
answers
12k
views
Geopandas reduce legend size (and remove white space below map)
I would like to know how to change the legend automatically generated by Geopandas. Mostly I would like to reduce its size because it's quite big on the generated image. The legend seems to take all ...