Hello!
I would like to add error bars to ggboxplot in a different color.
ggboxplot(ToothGrowth,x="dose",y="len",error.plot="errorbar",add="mean_se",
+ orientation="horizontal")
If I use the "color" attribute, the boxes take on the color. I just want the error bars to be a different color, please.
Thanks,
Erin
Hi!
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
Hi again.
I would like to produce a boxplot that has error bars. The boxplot itself should be black, while the error bars should be red.
Here is the initial code:
library(ggpubr)
Loading required package: ggplot2
data(ToothGrowth)
ggboxplot(ToothGrowth,x="dose",y="len",group="len",
+ add="mean_se",error.plot="errorbar")
Everything is black. Now I add the color attribute:
ggboxplot(ToothGrowth,x="dose",y="len",group="len",
+ add="mean_se",error.plot="errorbar",color="red")
So both the box and the error bars are red.
How would I go about having just the error bars be red, please?
Thank you,
Erin
Here is the solution:
ggboxplot(ToothGrowth,x="dose",y="len",group="dose",
+ add="mean_se",error.plot="errorbar",add.params=list(color="red"))
Thanks,
Erin
system
Closed
May 9, 2021, 2:52pm
5
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.