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.

legend
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 ...
Osmond Bishop's user avatar
59 votes
7 answers
80k views

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's user avatar
  • 1,051
58 votes
1 answer
47k views

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 ...
Psychologeek's user avatar
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 ...
user1850133's user avatar
  • 2,923
56 votes
7 answers
200k views

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 = fig.add_subplot(111) ...
Yehuda's user avatar
  • 1,883
56 votes
4 answers
81k views

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] ...
niboshi's user avatar
  • 1,478
55 votes
5 answers
117k views

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 ...
Gabriel's user avatar
  • 42.1k
54 votes
5 answers
75k views

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 ...
firefly's user avatar
  • 983
54 votes
6 answers
92k views

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 ...
Foad S. Farimani's user avatar
52 votes
2 answers
56k views

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 ...
Atticus's user avatar
  • 793
51 votes
3 answers
106k views

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 ...
Rahul's user avatar
  • 765
50 votes
2 answers
55k views

How to make custom legend

I currently generate my legend with matplotlib this way: if t==25: l1,l2 = ax2.plot(x320,vTemp320,'or',x320,vAnaTemp320,'-r') elif t==50: l3,l4 = ax2.plot(x320,vTemp320,'ob',x320,vAnaTemp320,'-...
tune2fs's user avatar
  • 7,697
48 votes
1 answer
101k views

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 ...
cassandra's user avatar
  • 627
47 votes
5 answers
35k views

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's user avatar
46 votes
5 answers
86k views

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 ...
user545424's user avatar
  • 16.1k

15 30 50 per page