Showing error distributions in a point plot

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Showing error distributions in a point plot

phil-3
I have a point plot where the estimated points have normally distributed
errors and I want to plot not just the estimated points, but also an
indication of the range of uncertainty in each case. The usual way of
doing this, I believe, is with geom_pointrange, as shown in my reprex.
However, this suggests to the eye that the errors are uniformly
distributed when in fact they are normally distributed. I would prefer
to show bell curves instead of straight lines. As far as I have been
able to determine, there is no R package to help in doing this. I would
appreciate suggestions as to how best to proceed.

Philip

# Reprex for error distributions
library(ggplot2)
df <- data.frame(x=1:10,y=rnorm(n=10))
ggplot(df)+
   geom_point(aes(x=x,y=y))+
   geom_hline(yintercept=0)+
   geom_pointrange(aes(x=x,y=y,ymin=y-sd(y),ymax=y+sd(y)))

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Showing error distributions in a point plot

Bert Gunter-2
Search for "violin plots"  at rseek.org.
There is a whole package devoted to them, many packages provide them, and
there is a geom_violin in ggplot2.

Don't know if this satisfies your aesthetic sensibilities, of course.
That's for you to decide.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Jan 11, 2021 at 7:42 AM <[hidden email]> wrote:

> I have a point plot where the estimated points have normally distributed
> errors and I want to plot not just the estimated points, but also an
> indication of the range of uncertainty in each case. The usual way of
> doing this, I believe, is with geom_pointrange, as shown in my reprex.
> However, this suggests to the eye that the errors are uniformly
> distributed when in fact they are normally distributed. I would prefer
> to show bell curves instead of straight lines. As far as I have been
> able to determine, there is no R package to help in doing this. I would
> appreciate suggestions as to how best to proceed.
>
> Philip
>
> # Reprex for error distributions
> library(ggplot2)
> df <- data.frame(x=1:10,y=rnorm(n=10))
> ggplot(df)+
>    geom_point(aes(x=x,y=y))+
>    geom_hline(yintercept=0)+
>    geom_pointrange(aes(x=x,y=y,ymin=y-sd(y),ymax=y+sd(y)))
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Showing error distributions in a point plot

phil-3
Yes, geom_violin does the trick. Thanks for your fast and useful reply,
Bert.

Philip

On 2021-01-11 11:05, Bert Gunter wrote:

> Search for "violin plots"  at rseek.org [1].
> There is a whole package devoted to them, many packages provide them,
> and there is a geom_violin in ggplot2.
>
> Don't know if this satisfies your aesthetic sensibilities, of course.
> That's for you to decide.
>
> Cheers,
> Bert
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Mon, Jan 11, 2021 at 7:42 AM <[hidden email]> wrote:
>
>> I have a point plot where the estimated points have normally
>> distributed
>> errors and I want to plot not just the estimated points, but also an
>>
>> indication of the range of uncertainty in each case. The usual way
>> of
>> doing this, I believe, is with geom_pointrange, as shown in my
>> reprex.
>> However, this suggests to the eye that the errors are uniformly
>> distributed when in fact they are normally distributed. I would
>> prefer
>> to show bell curves instead of straight lines. As far as I have been
>>
>> able to determine, there is no R package to help in doing this. I
>> would
>> appreciate suggestions as to how best to proceed.
>>
>> Philip
>>
>> # Reprex for error distributions
>> library(ggplot2)
>> df <- data.frame(x=1:10,y=rnorm(n=10))
>> ggplot(df)+
>> geom_point(aes(x=x,y=y))+
>> geom_hline(yintercept=0)+
>> geom_pointrange(aes(x=x,y=y,ymin=y-sd(y),ymax=y+sd(y)))
>>
>> ______________________________________________
>> [hidden email] 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.
>
>
> Links:
> ------
> [1] http://rseek.org

______________________________________________
[hidden email] 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.