Skip to content

Plot resolution problem when using fig.asp and rendering R Notebook (Retina display) #2098

Closed

Description

@gregrs-uk

System details

RStudio Edition : Desktop
RStudio Version : 1.1.419
OS Version      : OS X 10.11.6 (on a MacBook Pro Retina 13-inch, Early 2015)
R Version       : 3.4.3 (2017-11-30)

Steps to reproduce the problem

  1. File > New File > R Notebook.

  2. Replace the contents of the file with the following, removing the backslashes. (Sorry, I had to add these to prevent GitHub from messing up the formatting.)

---
output: html_notebook
---

Here is a plot.

\```{r}
plot(cars)
\```

Here is the same plot with `fig.asp` set.

\```{r fig.asp = 1}
plot(cars)
\```
  1. Save the file with an .Rmd extension.

  2. Code > Run Region > Run All

Describe the problem in detail

Here's the first plot.

plot1

Here's the second plot.

plot2

The text and points in the second plot are very small compared with the first plot.

Describe the behavior you expected

Here's what the second plot looks like when the page is rendered using rmarkdown::render in command-line R.

plot2-correct

I've also noticed problems when using fig.width and fig.height. Behaviour has been different when I drag RStudio on to a second monitor so perhaps the issue is caused by my MacBook's retina display.

There's still a problem when viewing using the 'Preview' button, but not when knitting to HTML.

Activity

  1. ronblum commented on Feb 9, 2018

    @ronblum
    Contributor

    @gregrs-uk Thank you for raising the issue, and I will mark it as a bug for review. In the meantime, one workaround is to adjust the size with cex—e.g. par(cex = 2.5)—which will increase the size within the preview. However, you'll need to remove it when knitting the document.

  2. gregrs-uk commented on Feb 9, 2018

    @gregrs-uk
    Author

    Thanks for the workaround, Ron.

  3. gregrs-uk commented on May 1, 2019

    @gregrs-uk
    Author

    Looks like this is possibly related to #4521

  4. eleozzr commented on Nov 2, 2020

    @eleozzr

    But what if ggplot? how to fix it?

  5. stale commented on Feb 4, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  6. added
    stale
    and removed on Feb 4, 2021
  7. removed
    stale
    on Feb 4, 2021
  8. added this to the v1.6 milestone on Feb 12, 2021
  9. mikebessuille commented on Feb 12, 2021

    @mikebessuille
    Contributor

    We see quite a few issues related to plot resolution, so I don't want this issue to go stale. We'll try to look at it in 1.6

  10. megaraptor1 commented on Aug 27, 2022

    @megaraptor1

    This issue is still going on, at least for me. Plots in the Notebook are very small, but knitting the whole document displays them at their proper resolution. It's to the point where if I want to see the plot I have to knit the whole document.

  11. modified the milestones: Future-4, Later on Oct 31, 2022
  12. ronblum commented on Dec 2, 2022

    @ronblum
    Contributor

    Moving to Cherry Blossom, in order to verify that it's fixed by PR #12324. If it's not, we'll reassign it to the current milestone.

  13. modified the milestones: Later, Cherry Blossom on Dec 2, 2022
  14. jonvanausdeln commented on Feb 6, 2023

    @jonvanausdeln

    Verified with 2023.03.0-daily+280. The text and points of the plots are the same in each plot as expected.

  15. self-assigned this
    on Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions