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

VS Code feature request: Inline plots that respect chunk dimension options #287

Open
andrewheiss opened this issue Sep 29, 2023 · 8 comments

Comments

@andrewheiss
Copy link

andrewheiss commented Sep 29, 2023

In RStudio, chunks that generate plots follow the dimensions specified in the chunk options (currently only with in-chunk options, but eventually hopefully also with YAML-style chunk options too)

image

 

In VS Code, images do not appear inline and instead either show up in a separate panel (if {httpgd} is installed), or in a separate window:

image

 

This is also the case when using the visual editor mode:

image

 

It would be helpful for figuring out figure dimensions for documents if plots could appear using the specified chunk options. But that also might just be a limitation of VS Code and/or radian and/or {httpgd} and/or something else.

@jjallaire
Copy link
Contributor

Unfortunately we are sending plots to the R extension so can't directly manipulate the figure size as we can in RStudio. If there is a way to do this that we aren't aware of we are all ears to implement it!

@grst
Copy link

grst commented Oct 20, 2023

I think this would be solved if there was a way to execute R via jupyter (#204).

@Pindar777
Copy link

Pindar777 commented Oct 27, 2023

@andrewheiss could the use of out-width: X% as command inside the r-chunk be a solution?

@andrewheiss
Copy link
Author

@andrewheiss could the use of out-width: X% as command inside the r-chunk be a solution?

Since the plot appears in a separate window, changing the out-width doesn't change anything, and if the plot could appear inline like in RStudio,out-width would only modify the width, not the height, and wouldn't change the actual dimensions of the image, just how it is displayed.

image

@Pindar777
Copy link

@andrewheiss I used the mentioned option to shrink images in docx output since fig.height etc. did not work (as opposed to bookdown).

Your description of the window-output makes perfectly sense. In VSCode I just resize that window, though.

@MichelNivard
Copy link

Unfortunately we are sending plots to the R extension so can't directly manipulate the figure size as we can in RStudio. If there is a way to do this that we aren't aware of we are all ears to implement it!

Could you send the R code to usr/bin/Rscript via the terminal instead of to R? Then you could catch the output and render inline? Or does either vscode or the design philosophy of knitr prevent this?

@venpopov
Copy link

I'm bumping up this issue. I recently switched entirely to vscode for all my R and quatro coding, and the ability to render code output and plots is what I miss the most from Rstudio. Could the visual editor somehow take advantage of the the Notebook API: https://code.visualstudio.com/api/extension-guides/notebook which allows to serialize code chunk outputs, save them to disk and render them?

@andrewheiss
Copy link
Author

Bumping this again now that Positron is a thing. Because Positron is essentially VS Code, inline images don't appear inline, and they don't take the chunk dimensions

image

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

6 participants