3

How do I get VSCode to refresh the plot when making a new plot without needing to close the previous plot tab? Ideally, it should open up a new tab with the new plot next to the old one.

gif displaying the close tab to refresh plot problem

Moreover, when using Httpgd, even tho the plot refreshes without me having to close the previous plot, it opens up in a separate window outside VSCode. How do I get it to open up as a new tab like in the gif above?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
aryan
  • 51
  • 8
  • Is there a `"r.plot.useHttpgd"` call in your JSON settings, and, if so, is it set to `"r.plot.useHttpgd": false"` or `"r.plot.useHttpgd": true"`? For me, every time I produce a new plot the plot window in VSCode gets updated automatically, with the previous plots listed below the newest one, in the same window, separated by a divider that you can move to resize. – coip Feb 13 '22 at 19:50
  • @coip As I said, when I use `Httpgd`, ie `"r.plot.useHttpgd": true"`, the new plot opens up in a separate window outside VSCode. I do not know how to get it to appear inside, separated by a divider as you mentioned. – aryan Feb 13 '22 at 20:51
  • So when you have it set to `false` and plot something new, nothing will happen unless you first close the already-open plot? And when you switch it to `true` the plot will refresh except it'll pop out as a new window instead of just updating in the already-open plot viewer? – coip Feb 13 '22 at 21:40
  • @coip The answer to both your questions is "Correct". You correctly describe what's happening. – aryan Feb 14 '22 at 14:52
  • 1
    Have you done everything described here? --- https://stackoverflow.com/a/68958793/4342901 – coip Feb 14 '22 at 17:40
  • @coip Thank you very much! I hadn't come across this post earlier. It solved the problem! – aryan Feb 14 '22 at 18:35

2 Answers2

1

I had the exact same problem and what fixed it for me was simply, in vscode, going into:

Files > Preferences > Settings > section Extensions > scroll down and find R: find the section "Plot: Use Httpgd" and check it, and restart Vscode.

I can't confirm but I believe it might have started after installing the httpgd package, because I had the behavior you desire before installation, and the exact same behavior you experience after httpgd installation. Of course if my solution works for you (I hope), it will work under httpgd after and not the base default VsCode/R-plot viewer as in your gif.

BenMerSci
  • 11
  • 1
  • I have `Plot: Use Httpgd`, checked. The plot does refresh instantly, however, the plot opens up in a separate window outside of VSCode. I believe the SVG is rendered in a python script using Quartz 2D, as that is what the plot window says: `Quartz 2 [*]`, and the running program on my Dock says `Python` – aryan Feb 14 '22 at 14:49
  • 1
    Can you go to the same place where you checked **"Plot: Use Httpgd"** and search for **"R: Sesion Watcher"** instead and see if it is checked? If not, try checking it and restart VsCode. (See answer from Kun Ren: https://stackoverflow.com/a/62219641/11317245) – BenMerSci Feb 14 '22 at 16:44
  • Note: you might also need to reboot after the process. – BenMerSci Feb 14 '22 at 17:28
  • I have `R: Session Watcher` checked. Meanwhile, downloading the `httpgd` package from CRAN fixed my issue. Thank you! – aryan Feb 15 '22 at 08:21
0

@coip pointed out that the steps given on this stackoverflow post to me. Downloading the httpgd package from CRAN fixed the problem for me.

aryan
  • 51
  • 8