0

I'm having some troubles with errorbars in ggplot (R) similar to this problem in Python. My horizontal errobars are disappearing when using the scale_y function. Can you help me find a solution? The data is here.

My code is:

data_sac_ggplot <- ggplot(yeast_sac, aes(x=factor(day), y=mean_count, colour=yeastsample, group=c("low","high"))) +
  scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x), labels = trans_format("log10", math_format(10^.x))) +
  geom_line(size=0.8) +
  geom_point(size=2, shape=21, fill="white") +
  theme_bw()
data_sac_ggplot + geom_errorbar(aes(ymin=mean_count-low, ymax=mean_count+high), width=0.1, position=pd)
data_sac_ggplot + scale_y_log10(breaks=c(1000,10000,100000,1000000,10000000,100000000,1000000000))

Thanks!

Picture of plot:

Community
  • 1
  • 1
  • Have a look at your data file. I get an error when trying to read it: `In read.table("http://aeblerov.com/yeast_sac.txt", sep = "\t"): incomplete final line found by readTableHeader on 'http://aeblerov.com/yeast_sac.txt'`. It looks like everything is in one row. – Jaap Jun 02 '14 at 10:10
  • Where is that `pd` object? – gd047 Jun 02 '14 at 10:11
  • After manually fixing your data, I get another error: `Error in is.vector(breaks) : could not find function "trans_breaks"`. Where did read about that function? It doesn't seem to exist in `ggplot2`... – Jaap Jun 02 '14 at 10:22
  • @Jaap trans_breaks is in package {scales} – gd047 Jun 02 '14 at 10:26
  • There are two things missing in your sample dataset: the `pd` variable (as already mentioned by @GeorgeDontas) and the `high` variable. Please provide a dataset with all needed variables, else it's very hard to replicate your problem and thus give an answer which solves your problem. – Jaap Jun 02 '14 at 13:05
  • @GeorgeDontas the *pd* object was originally defined as *pd<-position_dodge(0.1)*, but since it doesn't mean anything here I have removed it – user3698683 Jun 02 '14 at 16:58
  • probably the same issue as http://stackoverflow.com/questions/5936112/rescaling-the-y-axis-in-bar-plot-causes-bars-to-disappear-r-ggplot2 – Ben Bolker Jun 02 '14 at 17:33
  • @BenBolker Thanks, but it doesn't seem possible to use coord cartesian to change to log scales.. – user3698683 Jun 05 '14 at 10:36

0 Answers0