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
2
votes
1 answer

Why doesn't geom_hline generate a legend in ggplot2?

I have some code that is plots a histogram of some values, along with a few horizontal lines to represent reference points to compare against. However, ggplot is not generating a legend for the lines. library(ggplot2) library(dplyr) ## Siumlate an…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
2
votes
1 answer

Legend in ggplot2, remove level

My data: df <- data.frame(sp = c(LETTERS[1:8]), tr = c("NS", "LS", "NS", "LS", "LS", "HS", "HS", "HS"), bv = c(14, 5, 11, 5.6, 21, 5.4, 2, 4.8), av = c(0.0, 14, 21, 48.4, 15, 55.6, 37, 66.2)) I do…
Mateusz1981
  • 1,817
  • 17
  • 33
2
votes
1 answer

R, ggplot2 add legend with different data frames (of different sizes)

I'm trying to make a simple geom_point plot using ggplot2, but I cannot get a legend to appear. I have two data frames I am plotting from that are different lengths (~2000 rows vs ~6000 rows). I have tried adding things like…
bski
  • 33
  • 1
  • 7
2
votes
2 answers

Histogram legend in R

I have a histogram of the form rm(list = ls()) set.seed(1) x1 <- rnorm(100, mean=1) x2 <- rnorm(100) hist(x1, col="black", ylim=c(0,30), xlim=range(pretty(range(x1, x2))), xlab="x-axis label", ylab="y-axis label", main="", cex.lab=1.3,…
marcel
  • 389
  • 1
  • 8
  • 21
2
votes
1 answer

add legend to ggplot2

I've been trying to add legend to my ggplot but failed miserably. I did go through other asks which were related to adding legends manually such as 1,2 but couldn't apply the answerson my ggplot. I tried the function scale_colour_manual but the…
tropicalbath
  • 121
  • 1
  • 1
  • 12
2
votes
1 answer

Removing Labels from Legend in ggplot2

I have the data frame below that I have graphed as shown. How can I limit the values shown in the legend to only the first three? In other words, I want it to only show "A", "B", and "C". graph_table <- read.table(header=TRUE, text=" names freq …
wesanyer
  • 982
  • 1
  • 6
  • 27
2
votes
0 answers

show legend for oxyplot pie chart

I want to have a beautiful legend. I read the documentation, but could not find this case. I have PlotView in xaml PlotView…
2
votes
0 answers

How to have a legend outside the plot in R?

I have a datset and am trying to have a plot with probability. My codes go like this: vp <- table(raising_vowels$realization, raising_vowels$pattern) vp Then, I tried to have a barplot via: barplot(prop.table(vp, 2), main='Convergence affected by…
2
votes
1 answer

Mismatch in legend/color in R plot

I created several plots in R. Occasionally, the program does not match the color of the variables in the plot to the variable colors in the legend. In the attached file (Unfortunately, I can't yet attach images b/c of reputation), the first 2 graphs…
David L
  • 47
  • 1
  • 5
2
votes
1 answer

Error with legend of ggplot graph

I have a data set with three variables: Index of Economic Freedom, Total GDP and GDP per capita of ten countries. I am trying to plot a graph, in which the size of the circles should be proportional to the GDP of each country. However, on the right…
D Pinto
  • 871
  • 9
  • 27
2
votes
1 answer

Change legend size in qplot (R)

I have a graph of a probability density function drawn from a data.frame that looks a bit like this: head(GroupA_long_raw) Block Trial TrialType Subject variable value 1 Block2 101 Regular Subject1 RT 1214 2 Block2 102 Regular…
HernanLG
  • 664
  • 3
  • 7
  • 18
2
votes
1 answer

Legend won't show

I can't seem to get a legend for my two geom_lines to show. I've tried a number of different solutions from previously asked questions, but nothing seems to be working. Some of those attempts are in the code below. nauyear <- c(2000, 2010, 2020,…
user5154533
2
votes
1 answer

Matplotlib Colorbar Display Digtis

How do I exactly specify the colorbar labels in matplotlib? Frequently, I need to create very specific color scales, but the colorbar labels display so poorly you can't tell what the scale is. I would like to manually define the text next to the…
john_science
  • 6,325
  • 6
  • 43
  • 60
2
votes
1 answer

Adding a second legend with ggmap

I am trying to build a map which includes points of different color and size. I managed to add a legend for the color, but I cannot figure why the size scale doesn't show up. I made 3 attempts, each of them didn't lead to what I want. This is the…
OIE66
  • 23
  • 2
2
votes
2 answers

jquery cookies and Legend state

I'm using this code to activate disactivate the contents of fieldsets and jquery cookies plugin which works except for the state of the legend which always comes back as unselected which in turn sets the elements inside the fieldset to…
JoMojo
  • 404
  • 1
  • 7
  • 22
1 2 3
99
100