specify breaks for each panel

9 views
Skip to first unread message

baptiste auguie

unread,
Mar 19, 2009, 9:27:33 AM3/19/09
to ggp...@googlegroups.com
Hi list,

I've produced the graph shown below which looks fine except for the
y-labels of the middle row (too many).

load("test.rda")

p <-
ggplot(data = my.df2, mapping = aes(x = wavelength, y = value)) +
facet_grid(variable~regime, scale="free")+
layer(mapping=aes(colour=factor(pitch)), geom = c( "line"), stat =
"identity" ) +
scale_x_continuous(expression("wavelength / "*mu*m)) +
scale_y_continuous("") +
scale_colour_hue("h / nm", h=c(-120, 150)) +theme_bw()

To force the limits of each row to 1, 0, 0, respectively, I had to use
a trick of adding a geom_blank() with some dummy data,

lims <- data.frame(y = c(0, 1, 0), variable=factor(c("reflectance",
"transmittance", "absorbance")))

p +
geom_blank(data=lims, mapping=aes(y=y, x=0.6))

this does the job but I don't know how to change the number of breaks per panel.


Ideally, I would set something like,

p +
scale_y_continuous( limits = list(c(NA,1), c(0,NA),c(0,NA)),
breaks = list(seq(0.8, 1, by=0.2), seq(0, 0.02, by=0.005),
seq(0, 0.2, by=0.05)))

(that would be like the syntax in lattice)

Best regards,

baptiste


_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________

Rplot.png
test.rda

hadley wickham

unread,
Mar 20, 2009, 3:15:39 PM3/20/09
to baptiste auguie, ggp...@googlegroups.com
Hi Baptiste,

Those are some neat plots!

Unfortunately there is currently no way to set properties of
individual scales, and I'm not completely sure how it would work. I
think the breaks should be a property of facet_grid (because most of
the time scale_continuous wouldn't know how to deal with them). So
the syntax would look something like:

facet_grid( ...,
limits = list(c(NA,1), c(0,NA),c(0,NA)),
breaks = list(seq(0.8, 1, by=0.2), seq(0, 0.02, by=0.005),
seq(0, 0.2, by=0.05)))

Are there other properties of the scale that you also might want to
vary between facets?

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages