[R] Plotting confidence intervals with ggplot, in multiple facets.

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Jul 18 08:47:47 CEST 2021


ggplot(dta,aes(x=Ndat,y=estimate, ymin=lower,ymax=upper))+
  geom_point() +
  geom_errorbar(width=30) +
  facet_grid(param~1) +
  theme_minimal()

Width parameter seems odd... play with it I suppose.

For facets, you can also use facet_wrap(~param, ncol=1).

ggplot is very much about the data and the aes mapping... the more you try to manually tweak it the more messed up it tends to get. 

On July 17, 2021 11:17:06 PM PDT, Rolf Turner <r.turner using auckland.ac.nz> wrote:
>
>
>I have need of creating a plot displaying confidence intervals
>(for the mean bias in parameter estimates) with one panel or facet
>for each of the two parameters in question.
>
>I can do this in base R graphics, but the result is not as
>aesthetically pleasing as I would like.  I have attached an example
>graphic in the file "eg.pdf".
>
>I would like to try using ggplot2, but cannot get my head around the
>syntax.  (Life is a struggle when one is old and senile!)  I have been
>shown in the past how to produce a single-facet plot of such confidence
>intervals, basically using the geom_errorbar() function, but I cannot
>see how to produce multiple facets, depending on a "param" factor.  I
>have thrashed around a bit but after succeeding in only confusing
>myself, I thought I would save wear and tear on my brain by asking this
>list.  I'm sure the answer is pretty simple, but I'm just too stupid to
>see it.
>
>Can anyone give me a recipe for creating, with ggplot(), a graphic like
>unto that shown in "eg.pdf", but prettier?  I have attached the data
>that were used to create "eg.pdf" in the form of a data frame, in a
>file called "egData.txt".  This file was produced by dput() so read it
>in using dget("egData.txt").
>
>With eternal gratitude.
>
>cheers,
>
>Rolf Turner

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list