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.

A legend attached to a graph (or other visualization of data) is used to explain the graphical language (colors, symbols, lines, etc) of the specific visualization.

In scientific software for statistical computing and graphics and also , function legend adds a legend box to an existing plot.

4990 questions
55
votes
7 answers

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?
Mozammel
  • 1,011
  • 1
  • 13
  • 15
54
votes
4 answers

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] fig = pyplot.figure() ax =…
niboshi
  • 1,448
  • 3
  • 12
  • 20
53
votes
7 answers

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 =…
Yehuda
  • 1,787
  • 2
  • 15
  • 49
53
votes
1 answer

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 plot with ggplot2 and asked for the legend to…
Psychologeek
  • 641
  • 1
  • 5
  • 8
53
votes
5 answers

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 need to set this points to some other color not…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
51
votes
2 answers

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 legend title. How can I change the first one,…
Atticus
  • 783
  • 2
  • 6
  • 13
51
votes
5 answers

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 to read.
firefly
  • 953
  • 2
  • 11
  • 18
50
votes
3 answers

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 import seaborn as sns import numpy as…
Rahul
  • 755
  • 4
  • 8
  • 16
47
votes
6 answers

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 appreciate if you could help me know how I can edit/add…
Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
46
votes
1 answer

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 the legend is one example of the symbol. This plot…
Mark W
  • 795
  • 2
  • 7
  • 9
45
votes
1 answer

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 legend position (such as giving padding from the pie…
cassandra
  • 597
  • 1
  • 6
  • 9
44
votes
2 answers

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", 100) .attr("width",…
darko
  • 2,438
  • 8
  • 42
  • 54
44
votes
4 answers

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 matplotlib.pyplot as plt >>> x, y =…
user545424
  • 15,713
  • 11
  • 56
  • 70
43
votes
5 answers

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
Kevin Lindmark
  • 1,155
  • 3
  • 13
  • 26
43
votes
2 answers

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 legend maximum display "Maximum". There are posts…
nofunsally
  • 2,051
  • 6
  • 35
  • 53