Skip to main content
The 2024 Developer Survey results are live! See the results

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.

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 ...
Mark W's user avatar
  • 795
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", ...
user3115933's user avatar
  • 4,373
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 ...
nofunsally's user avatar
  • 2,091
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",...
darko's user avatar
  • 2,448
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 ...
nocss guy's user avatar
  • 433
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.
rhtica's user avatar
  • 565
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 ...
Adam Fraser's user avatar
  • 6,555
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 ...
Simon's user avatar
  • 751
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. ...
Mild Fuzz's user avatar
  • 30.3k
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. ...
hkBattousai's user avatar
  • 10.8k
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 <- ...
user avatar
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 ...
Covich's user avatar
  • 2,764
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 ...
screechOwl's user avatar
  • 27.9k
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("...
jslefche's user avatar
  • 4,549
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 * &...
jonathanbsyd's user avatar
  • 8,341

15 30 50 per page
1
3 4
5
6 7
345