Inline plot size and knitted plot size don't agree in RStudio on retina display










0















It turns out that setting plot sizes on a Mac with retina display can be challenging. I am not referring to file sizes or resolutions that can be taken care of with the fig.retina setting (I have seen several questions about that), but the fact that the actual figure layout differs between the inline version of a an RMarkdown script and both an exported version with the same dimensions (using ggsave) as well as a knitted version. Even small figure dimensions appear gigantic inline on the screen while they export and knit correctly. So, the ratio between font size and "plot size" (or whatever it would be called) appears to change. If I run the code on an older (non-retina) Macbook or a PC, the inline figure sizes are as expected.



enter image description here



This is an example of what I mean. The specified figure dimensions were fig.width=4, fig.height=3.



Is there a way to get the inline graph dimensions match the knitted versions...?



Thanks y'all!



edit: code included, not sure how reproducible it is though, since it might only be relevant to users with retina or 4k displays:



---
output: html_document
---

```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

```r, fig.width=4, fig.height=3
Pdata <- data.frame("X" = 1:10, "Y" = 1:10) # some data

ggplot(data = Pdata,aes(x = X,y = Y)) +
geom_point() +
theme_bw(base_size = 20) +
labs(x = "Some stuff", y = "Some more stuff")
```









share|improve this question
























  • You should include a reproducible example. Nobody can help you if we don't know what you did.

    – user2554330
    Nov 15 '18 at 20:40











  • Hm. Maybe I'm the only one with this particular issue...

    – Rincewind
    Nov 20 '18 at 16:46















0















It turns out that setting plot sizes on a Mac with retina display can be challenging. I am not referring to file sizes or resolutions that can be taken care of with the fig.retina setting (I have seen several questions about that), but the fact that the actual figure layout differs between the inline version of a an RMarkdown script and both an exported version with the same dimensions (using ggsave) as well as a knitted version. Even small figure dimensions appear gigantic inline on the screen while they export and knit correctly. So, the ratio between font size and "plot size" (or whatever it would be called) appears to change. If I run the code on an older (non-retina) Macbook or a PC, the inline figure sizes are as expected.



enter image description here



This is an example of what I mean. The specified figure dimensions were fig.width=4, fig.height=3.



Is there a way to get the inline graph dimensions match the knitted versions...?



Thanks y'all!



edit: code included, not sure how reproducible it is though, since it might only be relevant to users with retina or 4k displays:



---
output: html_document
---

```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

```r, fig.width=4, fig.height=3
Pdata <- data.frame("X" = 1:10, "Y" = 1:10) # some data

ggplot(data = Pdata,aes(x = X,y = Y)) +
geom_point() +
theme_bw(base_size = 20) +
labs(x = "Some stuff", y = "Some more stuff")
```









share|improve this question
























  • You should include a reproducible example. Nobody can help you if we don't know what you did.

    – user2554330
    Nov 15 '18 at 20:40











  • Hm. Maybe I'm the only one with this particular issue...

    – Rincewind
    Nov 20 '18 at 16:46













0












0








0








It turns out that setting plot sizes on a Mac with retina display can be challenging. I am not referring to file sizes or resolutions that can be taken care of with the fig.retina setting (I have seen several questions about that), but the fact that the actual figure layout differs between the inline version of a an RMarkdown script and both an exported version with the same dimensions (using ggsave) as well as a knitted version. Even small figure dimensions appear gigantic inline on the screen while they export and knit correctly. So, the ratio between font size and "plot size" (or whatever it would be called) appears to change. If I run the code on an older (non-retina) Macbook or a PC, the inline figure sizes are as expected.



enter image description here



This is an example of what I mean. The specified figure dimensions were fig.width=4, fig.height=3.



Is there a way to get the inline graph dimensions match the knitted versions...?



Thanks y'all!



edit: code included, not sure how reproducible it is though, since it might only be relevant to users with retina or 4k displays:



---
output: html_document
---

```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

```r, fig.width=4, fig.height=3
Pdata <- data.frame("X" = 1:10, "Y" = 1:10) # some data

ggplot(data = Pdata,aes(x = X,y = Y)) +
geom_point() +
theme_bw(base_size = 20) +
labs(x = "Some stuff", y = "Some more stuff")
```









share|improve this question
















It turns out that setting plot sizes on a Mac with retina display can be challenging. I am not referring to file sizes or resolutions that can be taken care of with the fig.retina setting (I have seen several questions about that), but the fact that the actual figure layout differs between the inline version of a an RMarkdown script and both an exported version with the same dimensions (using ggsave) as well as a knitted version. Even small figure dimensions appear gigantic inline on the screen while they export and knit correctly. So, the ratio between font size and "plot size" (or whatever it would be called) appears to change. If I run the code on an older (non-retina) Macbook or a PC, the inline figure sizes are as expected.



enter image description here



This is an example of what I mean. The specified figure dimensions were fig.width=4, fig.height=3.



Is there a way to get the inline graph dimensions match the knitted versions...?



Thanks y'all!



edit: code included, not sure how reproducible it is though, since it might only be relevant to users with retina or 4k displays:



---
output: html_document
---

```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```

```r, fig.width=4, fig.height=3
Pdata <- data.frame("X" = 1:10, "Y" = 1:10) # some data

ggplot(data = Pdata,aes(x = X,y = Y)) +
geom_point() +
theme_bw(base_size = 20) +
labs(x = "Some stuff", y = "Some more stuff")
```






r ggplot2 rstudio r-markdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 20:58







Rincewind

















asked Nov 15 '18 at 19:13









RincewindRincewind

296




296












  • You should include a reproducible example. Nobody can help you if we don't know what you did.

    – user2554330
    Nov 15 '18 at 20:40











  • Hm. Maybe I'm the only one with this particular issue...

    – Rincewind
    Nov 20 '18 at 16:46

















  • You should include a reproducible example. Nobody can help you if we don't know what you did.

    – user2554330
    Nov 15 '18 at 20:40











  • Hm. Maybe I'm the only one with this particular issue...

    – Rincewind
    Nov 20 '18 at 16:46
















You should include a reproducible example. Nobody can help you if we don't know what you did.

– user2554330
Nov 15 '18 at 20:40





You should include a reproducible example. Nobody can help you if we don't know what you did.

– user2554330
Nov 15 '18 at 20:40













Hm. Maybe I'm the only one with this particular issue...

– Rincewind
Nov 20 '18 at 16:46





Hm. Maybe I'm the only one with this particular issue...

– Rincewind
Nov 20 '18 at 16:46












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326447%2finline-plot-size-and-knitted-plot-size-dont-agree-in-rstudio-on-retina-display%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326447%2finline-plot-size-and-knitted-plot-size-dont-agree-in-rstudio-on-retina-display%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto