Zongtai Qi
2013-05-12 09:17:59 UTC
Greetings,
I'm new to the ggplot2 package and I'm trying to build a line graph.
The code is as below:
data <- read.csv ('my.data.csv',header =T)
library(ggplot2)
p <- ggplot(data,aes(x=stage,y=trans.effi, group = trans.method))
p + geom_point(size=6) +
theme_bw() + geom_line () +
scale_x_discrete (limits = c('stage1', 'stage2', 'stage3'))
data is my.data.csv file
my X axis is different stages
my Y axis is the values for the different stages
I just want to be able to specify the order of the labels on the x axis. In
this case, I'm trying to specify the order of "Stage". By default, it
orders alphabetically. How do I override this/keep the data in the same
order as in my original csv file?
I've tried this command
scale_x_discrete(limits=c("stage3","stage2","stage1"))
It however doesn't work very well, and give me missing error messages:
Error in if (zero_range(from) || zero_range(to)) return(rep(mean(to), :
missing value where TRUE/FALSE needed
Warning messages:
1: Removed 4 rows containing missing values (geom_point).
So the more general question is how to specify the order of ggplot2 x or y
axis instead of alphabetical order?
Thanks,
Zongtai
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
I'm new to the ggplot2 package and I'm trying to build a line graph.
The code is as below:
data <- read.csv ('my.data.csv',header =T)
library(ggplot2)
p <- ggplot(data,aes(x=stage,y=trans.effi, group = trans.method))
p + geom_point(size=6) +
theme_bw() + geom_line () +
scale_x_discrete (limits = c('stage1', 'stage2', 'stage3'))
data is my.data.csv file
my X axis is different stages
my Y axis is the values for the different stages
I just want to be able to specify the order of the labels on the x axis. In
this case, I'm trying to specify the order of "Stage". By default, it
orders alphabetically. How do I override this/keep the data in the same
order as in my original csv file?
I've tried this command
scale_x_discrete(limits=c("stage3","stage2","stage1"))
It however doesn't work very well, and give me missing error messages:
Error in if (zero_range(from) || zero_range(to)) return(rep(mean(to), :
missing value where TRUE/FALSE needed
Warning messages:
1: Removed 4 rows containing missing values (geom_point).
So the more general question is how to specify the order of ggplot2 x or y
axis instead of alphabetical order?
Thanks,
Zongtai
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.