geom-hline

How to avoid the crossing effect in legend with geom_vline() and geom_hline on the same scatter plot?

谁都会走 提交于 2021-02-16 14:26:52
问题 I created a scatter plot with geom_hline() and geom_vline() , the plot is good but the legend entries are not how I would like to make them appear. The vline (Restauration) and hline (Threshold) are crossing each other in the legend, making it confusing. I want the restauration legend entry to be an orange vertical line and the Threshold legend entry to be a horizontal black line. I tried several things suggested in other posts, with guide_legend(override.aes()) or with show.legend = F but

How to produce different geom_vline in different facets in R?

感情迁移 提交于 2019-12-04 20:33:33
问题 I am trying to produce 2 different geom_vlines with different colours in 2 different facets of a dataset. I am doing this to highlight means of 2 different facets. Here's the dataset: Pclass Sex Age SibSp Parch Fare Cabin Embarked Survived 3 male 22 1 0 7.25 S 0 1 female 38 1 0 71.2833 C85 C 1 3 female 26 0 0 7.925 S 1 1 female 35 1 0 53.1 C123 S 1 3 male 35 0 0 8.05 S 0 1 male 54 0 0 51.8625 E46 S 0 Here's the code: g<-ggplot(data = train3, aes(x = Age, y = Survived, colour = factor(Pclass))

How to produce different geom_vline in different facets in R?

非 Y 不嫁゛ 提交于 2019-12-03 13:14:24
I am trying to produce 2 different geom_vlines with different colours in 2 different facets of a dataset. I am doing this to highlight means of 2 different facets. Here's the dataset: Pclass Sex Age SibSp Parch Fare Cabin Embarked Survived 3 male 22 1 0 7.25 S 0 1 female 38 1 0 71.2833 C85 C 1 3 female 26 0 0 7.925 S 1 1 female 35 1 0 53.1 C123 S 1 3 male 35 0 0 8.05 S 0 1 male 54 0 0 51.8625 E46 S 0 Here's the code: g<-ggplot(data = train3, aes(x = Age, y = Survived, colour = factor(Pclass))) g<-g+facet_wrap(~Sex) g<-g+geom_point(size = 4, alpha = 0.2)+ggtitle("Survival by Gender")+theme(plot