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

All Questions

Tagged with
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
48 views

Removing underscores from ggplot2 boxplot [duplicate]

I would like to remove an underscore out of my ggplot2 boxplot (the head of fill "fungicide_treatment". I already tried to change the column head in my excel data file, and I tried already ...
Stephan Graßl's user avatar
0 votes
1 answer
236 views

My ggplot includes geom_boxplot and geom_line, but it does not show the legend for the geom_line part. How can I add it please?

My ggplot includes geom_boxplot and geom_line, but it only shows the legend for the boxplot part but does not show the legend for the geom_line part. How can I add it please? Note: The boxplot and the ...
Kelechi Igwe's user avatar
0 votes
1 answer
128 views

R - Boxplots from different datasets but same color legend

I have two datasets that represent the same, but one from simulated data and other from real data. I want to compare both with boxplots. So far, I did plot them as you can see in the image. The ...
Carlos Macarro's user avatar
1 vote
1 answer
894 views

Legend label combined plots (ggplot and patchwork)

I am new to R and trying to find a simple way to change the labels of the legend for combined boxplots created with ggplot and patchwork. I am comparing the proportions of 5 different types of cells ...
Elena's user avatar
  • 11
0 votes
1 answer
322 views

Cannot change ggplot boxplot legend name

I am using this code: library(ggplot2) library(reshape) mtcars <- melt(mtcars, id="am") mtcars$am <- as.character(mtcars$am) p <- ggplot(mtcars, aes(x = variable, y = value)) + ...
Sylvia Rodriguez's user avatar
2 votes
2 answers
4k views

How to add custom legend in ggboxplot

I'm trying to create some boxplots in R. I've been using both ggboxplot and ggplot. This is my code and output so far: ggboxplot: ggboxplot(shp_PA@data, x = "hei_1998to2007_cat", y = "...
L. Scott's user avatar
0 votes
2 answers
1k views

ggplot2 won't add legend to boxplot with multiple strata

I am attempting to add a legend to my boxplot with this example data BM math loginc 1 2 1.4523 0 3 2.3415 1 1 0.6524 1 3 2.4562 0 1 3.5231 ...
geoscience123's user avatar
0 votes
1 answer
859 views

Custom legend for geom_boxplot with connective mean line

I have combined ggplot boxplots with a connecting line which is the mean average. How could I create a legend so people know the blue circle points represent the mean average for each boxplot? ...
Brad's user avatar
  • 660
4 votes
2 answers
3k views

Change legend symbol from geom_boxplot symbol to a square

Can I change the symbol used in the legend for a boxplot? I would like to use a square instead of the boxplot symbol that is the default. I've tried the following after some searching, however the ...
ShellfishGene's user avatar
1 vote
2 answers
7k views

Legend customization for boxplots

I have this boxplots graph, and then I am trying to plot 2 different points on top of it, of different colors, so that the user can see where they fall on the boxplot, plus compare them to each other. ...
JustLearning's user avatar
1 vote
1 answer
3k views

How to customize a boxplot legend indicating mean, outliers, median, etc?

I have a boxplot and by my supervisor's advice I have to indicate the mean, outliers and median in the legend, like this image: How can I do this using ggplot2? library(ggplot2) A <- 1:20 DF <...
Daniel Valencia C.'s user avatar
0 votes
0 answers
58 views

How to add an extra shape item into a legend of fills using ggplot?

I made a filled boxplot, then I put a red cross in to highlight the group means. How can I add that red cross to the legend, if the legend was constructed using scale_fill_manual. I tried to use ...
Daniel Valencia C.'s user avatar
0 votes
1 answer
3k views

Order of the boxplots and legend labels with ggplot

I want to create a boxplot with ggplot2 and I'd like to organize the plot in the order of the data frame, e.g. I know that R organize the boxplot alphabetically. How can I: Organize the X ...
Daniel Valencia C.'s user avatar
1 vote
1 answer
314 views

Defining text for the legend of boxplot in ggplot2

How can I display a1 (random), a2 (random 2), a3 (random 3) in the legend instead of displaying the boxplot symbole? The code I'm working with is library(ggplot2) library(reshape2) B <- 25 ...
Fatima Batool's user avatar

15 30 50 per page