trix
May 4, 2020, 7:41pm
1
How do I plot one graph with lines that is ecdf_Q2<- 50,40,30,20, and 10 instead of just 50?? thank you!
ecdf_Q2 <- 50 %>%
ecdf.shift(ratio_threshold, .) %>%
filter(nobs > 20) %>%
ggplot(aes( x = OUR_ratio_cutoff, y = prob)) +
geom_rect(aes(xmin = 1.05, xmax = Inf, ymin = -Inf, ymax = Inf), fill = "red", alpha = 0.01) +
geom_line() +
geom_point() +
theme_bw(base_size = 12) +
theme(panel.grid = element_blank()) +
scale_y_continuous(limits = c(0,100),
breaks = seq(0,300, by = 10),
expand = c(0,0)) +
scale_x_continuous(limits = c(0,2),
breaks = seq(0,3, by = 0.1),
expand = c(0,0)) +
labs(x = "OUR ratio (-)",
y = "Probability of PE sCOD > 50")
top <- plot_grid(TSS_con_boxplot, TSS_con_hi, ecdf_Q2, ncol = 3, rel_widths = c(0.33, 1,1), align = "hv")
###########################################################################
ggplot works best when you put your data in a dataframe first.
Hi!
To help us help you, could you please turn this into a self-contained 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.…
trix
May 5, 2020, 4:24am
4
Thanks for your reply! will that allow me to have multiple lines in one graph with different target points? Ive been only using R for a week so everything's pretty confusing for me sorry!
Yes having your data in a dataframe will allow you to do all kinds of clever things with ggplot.
I recommend this free online book as the perfect way to learn R:
This book will teach you how to do data science with R: You’ll learn how to get your data into R, get it into the most useful structure, transform it, visualise it and model it. In this book, you will find a practicum of skills for data science. Just...
system
Closed
May 26, 2020, 5:23am
6
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.