-
Notifications
You must be signed in to change notification settings - Fork 37
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
Plots are rendered incorrectly in the RStudio plots pane when using the ggtext package #84
Comments
Same problem here; it seems not resolved yet. |
Hi, I found a work-around for ggplot objects generated in
|
Also running into a similar problem when using ggtext in plots that are generated with parallel processes, saved to serialized objects, and then reloaded in separate R sessions at a later point. I get external pointer errors that go away when I switch back to not using ggtext as a part of my plot objects. |
I encounter the same issue. If I source the code chunk below in one go, the second plot is visible and I cannot use the 'back' button in the RStudio 'Plots' pane to view
|
I'm not sure there's an easy way around this unfortunately. The layout code is written in C and so the ggtext data structures contain external pointers to C data structures, which are needed for rendering. Apparently those data structures get invalidated by the way the RStudio preview pane is implemented. Thinking some more about this, it may be a bug in RStudio. External pointers should not get invalidated for as long as a given R object that holds them is alive. So apparently RStudio somehow caches the plots but also signals to the R session that the objects are no longer valid. I'm not that familiar with these R internals, though, so I could be wrong. |
Thanks @clauswilke. That's frustrating, but I understand it's not a ggtext issue per se. |
Same here in july 24! Some recomendation to deal with it? |
An error in plot rendering happens in the RStudio plot viewing pane when using the "Next Plot" and "Previous Plot" forward and back buttons. The problem seems to be specific to plots generated with markdown elements using the "ggtext" package.
Here is a minimal example to reproduce the problem.
These plots are generated perfectly and can be saved using
ggsave()
and the like.However, a problem arises when viewing the plots in the RStudio plots pane. After executing the following code, each plot is rendered in the plots pane individually, with the last plot in
plot_list_aligned
appearing correctly.The problem arises when clicking RStudio's back button, located on the plots panel and which controls the "Previous Plot" functionality. After clicking on the back button for "Previous Plot" to view the first plot that was generated, the following error message appears in the console,
and the plot in the plot viewer pane appears incorrectly.
Saving the plot with
ggsave
orsave_plot
renders the plots correctly, so the issue appears to only affect the plot rendered in the RStudio plot pane. Next, clicking on the forward button for "Next Plot" to go back to the previously viewed plot (which had appeared correctly) now results in an additional error in the console.However, the plot appears to be correctly rendered in the plot pane despite the error.
The problem appears to involve the "ggtext" package, because when the plots are made without it, there is no such problem.
Viewing the plots made without the "ggtext" package individually, the first plot is rendered in the plot pane correctly.
Next, after clicking the back button for "Previous Plot" the first plot generated without "ggtext" is displayed and it looks correct. No error messages appear in the console, unlike when the plots were generated with "ggtext".
This problem was originally posted on stackoverflow, where the recommendation from the community there was to post the problem as an issue here.
The text was updated successfully, but these errors were encountered: