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

Intermittent error with theme(legend.text = element_markdown() when combined with colour scale #33

Open
ntthung opened this issue May 15, 2020 · 2 comments

Comments

@ntthung
Copy link

ntthung commented May 15, 2020

DF <- data.frame(x = rnorm(100), 
                 y = rnorm(100),
                 z = rnorm(100),
                 type = c(rep('C', 50), rep('delta', 50)))

ggplot(DF) +
  geom_point(aes(x, y, colour = z, shape = type)) +
  scale_shape_discrete(labels = function(x) ifelse(x == 'C', 
                                                   '<sup>14</sup>C',
                                                   '&delta;<sup>18</sup>O')) +
  scale_colour_distiller(palette = 'RdBu', direction = 1) +
  facet_wrap(vars(type)) +
  theme(legend.text = ggtext::element_markdown())

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport

and the figure comes without legend text:

image

The strange thing is that if I keep rerunning the code time after time, sometimes the plot can be rendered without error.

image

Versions:

  • R: 4.0.0
  • ggtext: 0.1.0
  • gridText: 0.1.1
@Jesse-Kerr
Copy link

Also having the same issue

@SAuderset
Copy link

SAuderset commented Jul 11, 2022

I have the same issue. It worked fine for a week and suddenly I get this error. Updated all my packages and installed the development version of ggtext, but nothing helps... The weirdest thing is that it only with some plots and not others, even though I use the exact same set up.

  • R version 4.2.0
  • ggtext 0.1.1
  • gridtext 0.1.4.9000

armack added a commit to armack/pdallele that referenced this issue Jun 7, 2023
Revert to standard `element_text()` as `ggtext::element_markdown()` in `legend.text` can cause `Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport` when combined with a color scale (potentially only with geom_point())

See wilkelab/ggtext#33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants