Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errorbars are not drawn if they extend outside of limits #3032

Closed
martin-ueding opened this issue Dec 10, 2018 · 2 comments
Closed

Errorbars are not drawn if they extend outside of limits #3032

martin-ueding opened this issue Dec 10, 2018 · 2 comments

Comments

@martin-ueding
Copy link

ggplot2 version: 3.1.0


When I start with a plot with errorbars, it works just fine:

library(ggplot2)

data = data.frame(x = 1:10, y = 1:10, dy = 1:10)

plot = ggplot(data, aes(x = x, y = y)) +
    geom_point() +
    geom_errorbar(aes(ymin = y - dy, ymax = y + dy))

plot-unrestricted

But when I restrict the limits of the plot, the errorbars which would extent outside of the plot region vanish:

plot2 = plot +
    ylim(0, 10)

plot-restricted

I would expect to still see the errorbars. We often have plots where some points have really small errors, and when the horizontal cross-bar is smaller than the point marker, one cannot distinguish points with vanishing error and from points with extremely large errors.

For reference, this is how Matplotlib does the same plot:

import matplotlib.pyplot as pl
import numpy as np

x = np.arange(1, 11)
y = x
dy = x

pl.errorbar(x, y, dy, marker='o', linestyle='none')
pl.ylim(0, 10)
pl.savefig('plot-matplotlib.png')

plot-matplotlib

I would wish that ggplot does this similarly.

@clauswilke
Copy link
Member

This is working as designed. See e.g. the bottom right corner of the ggplot2 cheatsheet:
https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf

@lock
Copy link

lock bot commented Jun 8, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jun 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants