geom_pointrange introduces streaks in ggplot

187 views
Skip to first unread message

ls

unread,
Apr 4, 2019, 7:23:31 PM4/4/19
to ggplot2
I'm using geom_pointrange to plot mean, max, and min in ggplot.  While the calculations and data are plotting more or less as expected, I'm getting intermittent "streaks" in my plot that changes with the size of the plot (when viewed in RStudio, saved as a jpeg, or saved as a high resolution tiff):

ggplot(data=data)+
geom_pointrange(mapping=aes(x=hrs, y=read2), stat="summary", fun.ymin=min, fun.ymax=max, fun.y=mean, alpha=0.3, shape=1)

streaks in geom_pointrange_2.jpegstreaks in geom_pointrange.jpeg

There are no axis limits that are cutting off vertical lines that are out of range.  The time step is the same for all data (10min) and each time point has the same number of data points (n=6).  If I stretch out the plot horizontally all points have vertical lines with similar error (there are no missing data from the stat summary or signal spikes in the data introducing large or no error).  Additionally as the period and number of overlaps/gaps change with plot size this doesn't seem to be an issue with the data.  I've tried recalculating hours for a ten minute time step with 12 instead of 7 significant figures but I still see the streaks.

Any suggestions?  Is there a jitter function in geom_pointrange that can be disabled?  Thanks in advance for your help!

Ben Bolker

unread,
Apr 4, 2019, 9:03:15 PM4/4/19
to ggp...@googlegroups.com

If your pointranges are so dense that the lines are overlapping and
causing graphical artifacts, you could try using geom_ribbon instead ...

On 2019-04-04 7:23 p.m., ls wrote:
> I'm using geom_pointrange to plot mean, max, and min in ggplot.  While
> the calculations and data are plotting more or less as expected, I'm
> getting intermittent "streaks" in my plot that changes with the size of
> the plot (when viewed in RStudio, saved as a jpeg, or saved as a high
> resolution tiff):
>
> ggplot(data=data)+
> geom_pointrange(mapping=aes(x=hrs, y=read2), stat="summary",
> fun.ymin=min, fun.ymax=max, fun.y=mean, alpha=0.3, shape=1)
>
> streaks in geom_pointrange_2.jpegstreaks in geom_pointrange.jpeg
>
> There are no axis limits that are cutting off vertical lines that are
> out of range.  The time step is the same for all data (10min) and each
> time point has the same number of data points (n=6).  If I stretch out
> the plot horizontally all points have vertical lines with similar error
> (there are no missing data from the stat summary or signal spikes in the
> data introducing large or no error).  Additionally as the period and
> number of overlaps/gaps change with plot size this doesn't seem to be an
> issue with the data.  I've tried recalculating hours for a ten minute
> time step with 12 instead of 7 significant figures but I still see the
> streaks.
>
> Any suggestions?  Is there a jitter function in geom_pointrange that can
> be disabled?  Thanks in advance for your help!
>
> --
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_hadley_devtools_wiki_Reproducibility&d=DwMFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=zImN_5GfvN5clExGCfuTCw&m=86BnMbgABr79y3Ql1nHR2Possyejpihj1V6VSZK5AfM&s=YDweiTbbFvZecr1BXnun5RVciTyB88lYTY7oks46URA&e=>
>  
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__groups.google.com_group_ggplot2&d=DwMFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=zImN_5GfvN5clExGCfuTCw&m=86BnMbgABr79y3Ql1nHR2Possyejpihj1V6VSZK5AfM&s=J552M4U_lOTbPuibpABqX7Ky58CkESpS9wm0AnczN3w&e=>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwMFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=zImN_5GfvN5clExGCfuTCw&m=86BnMbgABr79y3Ql1nHR2Possyejpihj1V6VSZK5AfM&s=ev5-8oTBsOP7eJCwjqLwD-2Pv-HAvETHW5erM0UCxKk&e=>.
Reply all
Reply to author
Forward
0 new messages