Skip to content

Skip picking a scale when the layer data is Inf#3192

Merged
yutannihilation merged 5 commits intotidyverse:masterfrom
yutannihilation:issue-3184-discrete-inf
Mar 20, 2019
Merged

Skip picking a scale when the layer data is Inf#3192
yutannihilation merged 5 commits intotidyverse:masterfrom
yutannihilation:issue-3184-discrete-inf

Conversation

@yutannihilation
Copy link
Copy Markdown
Member

@yutannihilation yutannihilation commented Mar 18, 2019

Fix #3184

In ggplot2, Inf might mean continuous value or discrete value. But, currently, the plot fails in the following case

  • the first layer's data is all Inf
  • the second layer's data is discrete

It seems better to skip picking a scale for the layer that has only infinite values. Note that, if all layers are such ones, the plot fails no matter we ignore them or not, because we cannot get a range for plots. So, I think this change is fine.

@clauswilke
Copy link
Copy Markdown
Member

What happens when all layers satisfy this condition?

@yutannihilation
Copy link
Copy Markdown
Member Author

I was thinking about that... I'm 90% sure it fails anyway, because it doesn't have a range. Am I missing something?

library(ggplot2)
library(patchwork)

p <- ggplot() +
  annotate("rect", xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = "black")

p / p + xlim(0, 1) + ylim(0, 1)

Created on 2019-03-19 by the reprex package (v0.2.1)

@clauswilke
Copy link
Copy Markdown
Member

I can confirm that it fails for the current ggplot2, so the patch is probably fine.

@yutannihilation yutannihilation marked this pull request as ready for review March 19, 2019 11:35
@yutannihilation yutannihilation merged commit 73599d2 into tidyverse:master Mar 20, 2019
@yutannihilation yutannihilation deleted the issue-3184-discrete-inf branch March 20, 2019 04:53
@lock
Copy link
Copy Markdown

lock Bot commented Sep 16, 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 Sep 16, 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

Successfully merging this pull request may close these issues.

when using annotation as first layer with x discrete and annotation xmin/xmax = -Inf/Inf error

2 participants