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

All Questions

Tagged with
1 vote
1 answer
30 views

How to Add a Legend to a ggplot with two axes

I've put together this graph and I would like to be able to add a legend to it but can't seem to figure out why it's not showing up and how to easily add it. data <- data.frame(group = LETTERS[1:5],...
Patrick Jung's user avatar
0 votes
1 answer
19 views

Centering a `ggplot2` Plot Legend in a Blank Plot

I have the following graph. ggplot() + geom_hline(aes(yintercept = 0, linetype = "Line 1"), color = "white", size = 1.25) + geom_hline(aes(yintercept = 0, linetype = "Line ...
David Moore's user avatar
0 votes
1 answer
37 views

Changing the Legend Title in a `ggpointdensity` Density Scatterplot [duplicate]

I have the following data and the following graph. df <- data.frame(col1 = rnorm(1000, 0, 0.05), col2 = rnorm(1000, 0, 0.05)) ggplot(data = df, mapping = aes(x = col1, y = col2)) + ...
David Moore's user avatar
0 votes
1 answer
68 views

Add legend after using gg.gap

I have a data set with a big negative value, so I used gg.gap package to make a discontinuous y-axis. The code worked well but after adding the function gg.gap the legend was deleted. I tried adding a ...
Gonzalo de Quesada's user avatar
2 votes
1 answer
44 views

How can I make the legend appear on this chart?

I've drawn this quartile for the runoff rate, and I'd like the legend to appear as: - Median and - Q25-Q75. Can you please help me? Runoff <- data.frame(Year = rep(1991:2002, each = 12), ...
Barre's user avatar
  • 31
0 votes
1 answer
39 views

I want to get two legends for two different groups in a two Y-Axis plot [closed]

so I have a two Y-Axis plot. Each Y-Axis is given a group of Data. I want to have two different legends for each group on left and right side of plot on the locations shown in the second picture. This ...
Nick Brown's user avatar
0 votes
0 answers
20 views

Change Orientation and Order of Items in Legend ggplot2 r [duplicate]

Is there a way to change the orientation of the items in the legend of ggplot2 chart? I have a series of boxplots where I would like the individual items to oriented vertically opposed to horizontally....
Englishman Bob's user avatar
0 votes
1 answer
29 views

Variable legend outlined in appropriate color, but filled with black dot

I have used ggplot in R to generate a dot plot with three "samples" (Adipocytes, BAT and WAT) which are colored by ""group". The plot is correct, but the "group" ...
Numbahs84's user avatar
0 votes
3 answers
39 views

Legend is not shown using ggplot2 despite using color within aes()

I have a problem making the plot legend to show. I've checked other posts and most of them mention that color should be defined within the aes() of the ggplot. So I have the following dataset: date ...
Tassos Pan's user avatar
1 vote
1 answer
16 views

Order of items in an R graph legend are different depending on different datasets of the same data

Newish to R and Stack Overflow but I wrote some R code to make grouped boxplots for chlorophyll data by season and site while including a water quality criteria reference line. It may not be the most ...
MrFury37's user avatar
0 votes
1 answer
64 views

How to center legend text in ggplot

I have a plot that looks like this: I used these data and code to produce it: structure(list(zone = c("Zone 1", "Zone 2", "Zone 3", "Zone 4", "Zone 5&...
Ryan Gary's user avatar
  • 141
2 votes
2 answers
178 views

Specify which legend to keep in wrap_plots

I'm looking to combine multiple graphs generated from different functions into a single display. Specifically, I want to only keep the legend of the first graph in the wrap. Here is a minimal version ...
NoNameBoyy's user avatar
0 votes
1 answer
46 views

Legend is not reflecting symbol plotted in ggplot2

I have a dataframe that looks like this: structure(list(season = c("Fall", "Spring", "Summer", "Winter" ), effort = c(2559.85453311966, 4741.60449074074, 2014....
Ryan Gary's user avatar
  • 141
1 vote
1 answer
149 views

Order of ggplot ignoring order of legends

With the following data, I am trying to create a plot as shown, but the order of legends as: mgCST Group, CST Group, Treatment Status. However, ggplot is ignoring all attempts to order the legends ...
AWillz's user avatar
  • 23
-1 votes
1 answer
40 views

Add horizontal lines with according color and legend to ggplot using R

I want to add horizontal lines so that the lines have y-intercept of period and colors according to their obj_name, ie the same colors as the line plot for each object. I succeeded in putting in these ...
Jason Liu's user avatar

15 30 50 per page