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
46
votes
1
answer
24k
views
How to create a scatter plot legend with only one symbol for each label?
How can I create a scatter plot legend without two symbols showing up each time? I can understand why you'd want this when you're joining symbols by lines, but for a pure scatter plot, all I want in ...
44
votes
2
answers
79k
views
How to increase the font size of the legend in seaborn
I have the following codes to create a Seaborn strip plot. I am having a hard time figuring out how to increase the font size of the legend appearing in the plot.
g=sns.stripplot(x="Market", ...
44
votes
2
answers
94k
views
Label minimum and maximum of scale fill gradient legend with text: ggplot2
I have a plot created in ggplot2 that uses scale_fill_gradientn. I'd like to add text at the minimum and maximum of the scale legend. For example, at the legend minimum display "Minimum" and at the ...
44
votes
2
answers
91k
views
Adding a chart legend in D3
I am having trouble adding a chart legend to my d3js chart. Here is my current approach:
var legend = svg.append("g")
.attr("class", "legend")
.attr("x", w - 65)
.attr("y", 25)
.attr("height",...
43
votes
10
answers
98k
views
How to position the legend inside a fieldset with a border? [duplicate]
According to the several references on the web, it is not possible to position a legend. So it is suggested to wrap it with span:
<legend><span>Foo</span></legend>
Then we ...
43
votes
1
answer
51k
views
How to adjust space between legend markers and labels
I want to adjust space between legend markers and labels. Sometime the space is too much as default. Does anyone know how to do this?
Thanks.
43
votes
3
answers
15k
views
How to create a draggable legend in matplotlib?
I'm drawing a legend on an axes object in matplotlib but the default positioning which claims to place it in a smart place doesn't seem to work. Ideally, I'd like to have the legend be draggable by ...
42
votes
1
answer
108k
views
R: legend with points and lines being different colors (for the same legend item)
Using the legend() function is it possible to have the point and line be different colors? I feel like I'm missing something fairly obvious. The pt.bg option can change the background color, but I'm ...
41
votes
2
answers
14k
views
Why won't my <legend> element display inline?
I am trying to apply display: inline; to the <legend> element in my <fieldset> element, so that the following <span> will follow on the same line, but my CSS is having no effect.
...
40
votes
6
answers
73k
views
How to show legend for only a specific subset of curves in the plotting?
t = 0 : 0.01 : 2 * pi;
s = sin(t);
c = cos(t);
m = -sin(t);
hold on;
plot(t, s, 'r');
plot(t, c, 'b');
plot(t, m, 'g');
hold off;
legend('', 'cosine', '');
There are several curves in my plotting. ...
39
votes
3
answers
47k
views
How to reverse legend (labels and color) so high value starts at bottom?
whats the best way to invert the legend label order so the 7 is down and the 1 is upstairs?
df$day <- as.numeric(df3$day)
blues <- colorRampPalette(c('#132B43', '#56B1F7'))
p4 <-
...
39
votes
2
answers
55k
views
How to make a colored markers legend from scratch
In Matplotlib, I'm trying to make a legend with colored "markers" like this one :
this one has been made using the scatter function, but is not adapted to my plot. I'd like to produce a ...
39
votes
4
answers
190k
views
R legend placement in a plot
I have a plot that has data that runs into the area I'd like to use for a legend. Is there a way to have the plot automatically put in something like a header space above the highest data points to ...
39
votes
2
answers
21k
views
Position legend in first plot of facet
I would like to put my plot legend inside the plot, inside the first plot of a facet.
Here is some example code:
df=data.frame(
x=runif(10),
y=runif(10),
facet=rep(c("a","b"),5),
color=rep(c("...
39
votes
2
answers
44k
views
Matplotlib legend, add items across columns instead of down
For a simple plot below, is there a way to make matplotlib populate the legend so that it fills the rows left to right, instead of first column then second column?
>>> from pylab import *
&...