[R] Plotting confidence intervals with ggplot, in multiple facets.
Bill Dunlap
w||||@mwdun|@p @end|ng |rom gm@||@com
Tue Jul 20 02:21:23 CEST 2021
ggplot2::labs() interprets expressions as plotmath. E.g.,
data.frame(X=1:10,Y=(1:10)^2) %>% ggplot(aes(X,Y)) + geom_point() +
labs(x = expression(beta), y = expression(beta^2))
-Bill
On Mon, Jul 19, 2021 at 4:24 PM Rolf Turner <r.turner using auckland.ac.nz> wrote:
>
>
> Thanks to Jeff Newmiller, Rui Barradas and Avi Gross for their
> extremely helpful replies. I have got both Jeff's and Rui's code to
> run. I am currently experimenting with Avi's suggestion of producing
> multiple plots and then putting them together using plotgrid() or
> grid.arrange(). This idea seems to me to be most promising in terms of
> a desideratum that the y-axis scales/limits should be different on the
> two facets. Also the y-axis labels.
>
> And speaking of y-axis labels: is it possible in ggplot() to get
> mathematical notation in axis labels, titles and possibly other
> annotation? (In the manner of plotmath() in base R graphics.)
> Specifically I'd like to get the Greek letters alpha and beta in the
> y-axis labels. In base R graphics I'd do something like
> ylab=expression(paste("bias in ",beta)) . Is there an appropriate
> analogue in ggplot()? (I think that I may have asked this question
> before, some time back, but have forgotten the answer.)
>
> cheers,
>
> Rolf
>
> P.S. The following is kind of apropos of nothing, but it might serve as
> a useful warning to others of a Trap for Young Players. I nearly went
> mad (madder?) for a very long time when trying to get Rui's code to run.
> I kept getting errors of the form:
>
> > Error in source("scr.Rui") : scr.Rui:6:2: unexpected input
> > 5: ggplot(eg, aes(Ndat, estimate)) +
> > 6:
> > ^
>
> Took me an unconscionably long while to figure out what was going on.
> I could not see why Jeff's code ran without problem, while Rui's (which
> was very similar) fell over. Turns out the second character in the
> offending line is a non-printing character, the 160th member of the
> ASCII character set. (It can be produced using "\u00A0".) Apparently
> this is a "non-breaking space". Whatever that means. It does NOT get
> treated as white space in the usual way, and triggers the foregoing
> error.
>
> Presumably this invisible character got introduced, into the code that
> Rui emailed, by one of the (many!) infuriating idiosyncrasies of
> Windoze. Yet another reason, among the many millions of such, not to
> use Windoze.
>
> R.
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list