Remove horizontal lines (ggplot2)
Date : March 29 2020, 07:55 AM
will help you You can find the solution how to hide the horizontal lines also in the Cookbook for R. Just look at the end of the Link i´ve posted in the thread.
|
ggplot2 draw dashed lines of same colour as solid lines belonging to different groups
Tag : r , By : Ivan Kitanovski
Date : March 29 2020, 07:55 AM
it should still fix some issue To add dotted lines you should add 2 geom_line() call where you provide y values inside aes(). There is no need to put data= and groups= arguments as they are the same as in ggplot() call. linetype="dotted" should be placed outside aes() call. For the colors you need only one scale_color_manual(). To remove dotted line pattern from legend you can override aesthetic using functions guides() and guide_legend(). ggplot(data, aes(x = x, y= mean, group = as.factor(data$group),
colour=as.factor(data$group))) +
geom_line() + geom_point() +
geom_line(aes(y=lower),linetype="dotted") +
geom_line(aes(y=upper),linetype="dotted")+
scale_color_manual(name="Groups",values=c("red", "blue"))+
guides(colour = guide_legend(override.aes = list(linetype = 1)))
|
Horizontal barplot in ggplot2 with faces having different categories
Tag : r , By : Dominique Vocat
Date : March 29 2020, 07:55 AM
it should still fix some issue Ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip. So either you could plot them without flip: ggplot(d,aes(y=qty,x=prd)) +
facet_wrap(~cat, scale="free") +
geom_bar(stat="identity") +
theme_light()
d$n <- paste(d$cat, d$prd, sep="|")
ggplot(d,aes(y=qty,x=n)) +
geom_bar(stat="identity") +
coord_flip() +
theme_light()
|
How to add horizontal lines showing means for all groups in ggplot2?
Date : March 29 2020, 07:55 AM
With these it helps Is there a way to place horizontal lines with the group means on a plot without creating the summary data set ahead of time? I know this works, but I feel there must be a way to do this with just ggplot2. , Expanding on my comment: ggplot(X, aes(x = x, y = y, color = grp)) +
geom_point(shape = 19) +
stat_smooth(method="lm", formula=y~1, se=FALSE)+
theme_bw()
library(quantreg)
ggplot(X, aes(x = x, y = y, color = grp)) +
geom_point(shape = 19) +
stat_smooth(method="rq", formula=y~1, se=FALSE)+
theme_bw()
|
ggplot2: how to sort the categories in horizontal bar charts?
Tag : r , By : Tonci Grgin
Date : March 29 2020, 07:55 AM
should help you out I removed some useless parts like the group, used 'modernized' geom_col(), but the trick was probably in doing sum per factor level instead of mean, which is the default for reorder. Consistently using the tidyverse functions usually saves you from unpleasant surprises, even if reorder would work here as well. library(tidyverse)
dataframe %>%
mutate(text = text %>% forcats::fct_reorder(count, sum)) %>%
ggplot(aes(x = text, y = count, fill = count)) +
geom_col() +
facet_wrap(~ group, scales = "free_y") +
coord_flip()
|