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

All Questions

0 votes
1 answer
41 views

Changing Title of Legend in ggplot2 Creates a Second Legend?

I am pretty new to R/working with data and am trying to change the title of the legend in a visualization I made. I have tried using fill= in the labels() function I have but it adds another legend ...
aoao's user avatar
  • 3
1 vote
1 answer
173 views

How to remove the square surrounding legend keys in a plot made by plot_model (ggplot) in R

I'm currently working on creating some complex visualizations using the plot_model function from the sjPlot package in R. Specifically, I'm dealing with interaction plots of linear models, and I'm ...
Zaida's user avatar
  • 35
0 votes
1 answer
47 views

How to have legend for multiple stat_function

I am creating the following graphs data <- runif(100, 15, 45) df <- data.frame(data) graph_parameter_product <- function(data_set, column_value, bin_width, title_value) { graph <- ...
Joe the Second's user avatar
2 votes
1 answer
831 views

Legend that shows points vs lines in ggplot2

I am trying to generate a legend in ggplot that shows points with a different name than lines. I need that legend to show up separately from the legend that is showing color, shape, and linetype. I ...
Sierra Johnson's user avatar
1 vote
1 answer
464 views

Add a legend to a ggplot pointrange figure

I developed this point range graph and want to add a legend to explain what the black dots (median) and horizontal lines (range) represents as well as what the vertical dashed line (overall median) ...
Hazem's user avatar
  • 57
0 votes
0 answers
508 views

Limit Number of Items Displayed in Legend - GGplot R

I have a large taxonomic dataset that I need to plot as a stacked bar chart. Sample Data: ID X A B C D E F G 1 5 9 6 7 4 8 10 6 2 6 3 9 10 3 10 4 8 3 6 ...
John Conor's user avatar
0 votes
1 answer
737 views

Changing point size and colour in GGplot2 legend

I have a plot that looks like this I would like to modify the legend so that the points on the lines are the same colour as the points on the plot, but also larger, so that they are visible against ...
PhelsumaFL's user avatar
1 vote
1 answer
178 views

Creating completely customized legends in ggplot2

I am wondering if it is possible to create a completely customized legend for a ggplot figure, that does not take into consideration any of the shapes, sizes, column names, etc. used in the given ...
Cameron's user avatar
  • 308
0 votes
1 answer
145 views

Adding legend to ggplot for forecasts

I have a ggplot for the different forecasts I used. Can you please help me add labels for the different forecasts? I pasted a copy of the code and a picture of the current graph. Don't mind the title, ...
MacroChair's user avatar
0 votes
0 answers
261 views

R: adding a legend to a density plot

I am working with the R programming language. I am following this tutorial here on density plots: https://www.r-graph-gallery.com/2d-density-plot-with-ggplot2.html I am trying to figure out how to add ...
stats_noob's user avatar
  • 5,705
0 votes
1 answer
168 views

Add a combined legend that accounts for color, shape, and linetype, while keeping the original legends

I have the following df: df <- data.frame("id" = c("A1", "A1", "A1", "A2", "A2", "A2", "B1", "B1", "B1&...
Thredolsen's user avatar
2 votes
1 answer
505 views

ggplot2 - Show multiple keys (shapes) in size legend

I have an issue related to displaying legends. I am not even sure it is something I can solve with ggplot, but since I am quite a basic user of R, I am confident it is just my ignorance to speak for ...
Filippo Santi's user avatar
0 votes
0 answers
175 views

How can I add a custom legend in ggplot2?

I have a following code for my ggplot in which some countries have same colour in horizontal bar chart. p <- ggplot(sample, aes(x = reorder(sample$Country, sample$size), y = sample$size,fill = ...
Anup Sakpal's user avatar
1 vote
1 answer
126 views

Duplicate legends in overlayed density plots using ggplot2

I am trying to generate density plot with two overlaid distributions using ggplot2. My data looks like: diag_elements <- data.frame(x = c(diag(Am.dent), diag(Am.flint)), ...
shbrainard's user avatar
2 votes
0 answers
446 views

Changing legend title and labels in geom_col ggplot2

I wish to change the title and labels of a legend in geom_col plot in ggplot2. I have tried to use the functions below to change the legend title, however nothing happens: labs(color = "Treatment") ...
Tiptop's user avatar
  • 603

15 30 50 per page