Reputation: 1117
I have the the DF
data.frame
. I want to plot
the cumulative distribution function (CDF)
of the variables
in DF
using ggplot
. using the following code produce the plot
but because of big range in the data for variables
i don't see the plot
well. I don't want to use multiple facets
- would like to have all of the variables
plotted
on the single panel
.
library(ggplot2)
set.seed(123)
DF <- melt(data.frame(p1 = runif(200,1,10), p2 = runif(200,-2,1), p3 = runif(200,0,0.05),p4 = runif(200,100,4000)))
ggplot(DF, aes(x = value, col = variable))+
stat_ecdf(lwd = 1.2)
Upvotes: 0
Views: 1825
Reputation: 41260
If you don't want to use facets, you could use a log scale:
library(ggplot2)
set.seed(123)
DF <- reshape::melt(data.frame(p1 = runif(200,1,10), p2 = runif(200,-2,1), p3 = runif(200,0,0.05),p4 = runif(200,100,4000)))
ggplot(DF, aes(x = value, col = variable),log='x')+
stat_ecdf(lwd = 1.2)+
scale_x_log10()
Upvotes: 2
Reputation: 887881
We can use facet_wrap
to identify
ggplot(DF, aes(x = value, col = variable))+
stat_ecdf(lwd = 1.2) +
facet_wrap(~ variable)
Upvotes: 2