Questions tagged [legend-properties]

legend-properties refers to various chart libraries and the ability to programmatically customise legends in charts generated by those libraries.

legend-properties refers to various chart libraries and the ability to programmatically customise legends in charts generated by those libraries. Examples for proper use of the tag is :

413 questions
106
votes
4 answers

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, and the value can be right, left, top, bottom, none…
Dan Goldstein
  • 24,229
  • 18
  • 37
  • 41
70
votes
4 answers

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]] data_BS_Y = data[channels[2]] plot_BS_P =…
N.K.
  • 733
  • 1
  • 5
  • 9
56
votes
3 answers

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 because it disturbs the text reading. The keyword…
user1850133
  • 2,833
  • 9
  • 29
  • 39
56
votes
3 answers

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 anyone know if there is a possible way to do…
Osmond Bishop
  • 7,560
  • 14
  • 42
  • 51
33
votes
1 answer

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 around all the…
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
33
votes
2 answers

Matplotlib automatic legend outside plot

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] plt.subplot(211) plt.plot(x,…
edesz
  • 11,756
  • 22
  • 75
  • 123
32
votes
3 answers

Set the legend location of a pandas plot

I know how to set the legend location of matplotlib plot with plt.legend(loc='lower left'), however, I am plotting with pandas method df.plot() and need to set the legend location to 'lower left'. Does anyone know how to do it? Edited: I am actually…
Daniel Lima
  • 925
  • 1
  • 8
  • 22
29
votes
4 answers

Pie Chart Legend - Chart.js

I need help to put the number of the pie chart in the legend Chart Image If i hover the chart with mouse i can see the number relative to each item i want to display it in the legend either the important code so far: var tempData = { labels:…
dpanegassi
  • 649
  • 4
  • 8
  • 15
26
votes
3 answers

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
jQuery var data =…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
26
votes
5 answers

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 = '#3399ff') + geom_point(aes(x = year,y =…
S12000
  • 3,345
  • 12
  • 35
  • 51
21
votes
1 answer

Plot legend below the graphs and legend title above the legend in ggplot2

I have a dataframe df: structure(list(y = c(2268.14043972082, 2147.62290922552, 2269.1387550775, 2247.31983098201, 1903.39138268307, 2174.78291538358, 2359.51909126411, 2488.39004804939, 212.851575751527, 461.398994384333, 567.150629704352,…
SimonB
  • 670
  • 1
  • 10
  • 25
21
votes
1 answer

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 with geom_text I would like to make the legend of…
Trevor Nederlof
  • 2,546
  • 5
  • 22
  • 40
20
votes
3 answers

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 but I can only find how to change the font size in…
Stu
  • 301
  • 1
  • 2
  • 4
17
votes
2 answers

Different legend-keys inside same legend in ggplot2

Let's say I don't need a 'proper' variable mapping but still would like to have legend keys to help the chart understanding. My actual data are similar to the following df df <- data.frame(id = 1:10, line = rnorm(10), points =…
Michele
  • 8,563
  • 6
  • 45
  • 72
16
votes
2 answers

Add a horizontal discrete legend below the chart in ggvis

I'd like to make a horizontal legend below the ggvis chart. I can use legend properties to place it below the chart, but don't know how to make the labels horizontal below the legend title. Below is the minimum reproducible code (grabbed from the…
chungkim271
  • 927
  • 1
  • 10
  • 20
1
2 3
27 28