Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot non-standardized data with ggplot2?

Tags:

plot

r

ggplot2

I plot Iris data with ggplot2. It seems ggplot2 will standardized the data to (0.1) interval automatically. How can I plot the data without any standardized manipulation?

library(ggplot2)
p <- ggpcp(iris, vars = names(iris[1:4]))
p + geom_line(aes(color = Species)) + ylim(0,8)

I am not a native English speaker and I am sorry to make ambiguity. Actually, the iris data various from 0 to 8. I want to plot the data exactly reflected the real value, but not the standardized value (transform the original data to (0,1) interval).

like image 541
Jill Clover Avatar asked Apr 09 '26 19:04

Jill Clover


1 Answers

Maybe:

library(ggplot2)
p <- ggpcp(iris, vars = names(iris[1:4]))
iris2 <- data.frame(id=1:nrow(iris), iris)
dat <- reshape2::melt(iris2,id.var = c("id", "Species"))
ggplot(aes(y=value, x=variable, group=id, color=Species), data=dat) + geom_path()

enter image description here

Though there may be better ways. Never did this so it was fun trying.

like image 67
Tyler Rinker Avatar answered Apr 12 '26 10:04

Tyler Rinker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!