nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
377 stars 19 forks source link

How to replace the default plot device with httpgd? #70

Closed jooyoungseo closed 2 years ago

jooyoungseo commented 3 years ago

I was wondering if there would be recommended way to replace the default plot device with httpgd.

As I want to have plots open in my external browser automatically, I added the following to my .Rprofile:

options(device = function(...) {
    httpgd::hgd(silent = TRUE)
    httpgd::hgd_browse()
})

However, the issue is that it opens browser only one time and does not open again once I close the browser windows.

Let me give you an example below:

# With the options that I specified above.
## The following is plotted in browser and opened automatically:
hist(airquality$Ozone)

## This one is also displayed in the already-opened browser:
hist(airquality$Ozone, col = "red")

## Close the browser.
## The following does not open browser unless I manually invoke `httpgd::hgd_browse()`
boxplot(cars$speed, col = "blue")

Do you have any advice?

renkun-ken commented 3 years ago

If you are using httpgd within vscode-R, then using options(vsc.use_httpgd = TRUE) will reveal the plot viewer when the plot is updated.

jooyoungseo commented 3 years ago

Yes, I use that option in VSCode, but for some complicated reason, I need to use external browser instead of the VScode plot panel.

renkun-ken commented 3 years ago

If you have to use an external browser, then I guess it might not make sense to open a new window whenever the plot is updated. The plot does not know there might be already an existing window.

nx10 commented 2 years ago

Closing this for now, if you have any further questions or feature requests please respond and I will reopen.

VitorAguiar commented 1 year ago

The plot panel does not work for me. I am using VSCODE to ssh into a remote server. I checked the option "Use Httpgd" in the settings, and also added "options(vsc.use_httpgd = TRUE)" to my .Rprofile. However, the plots still go to x11().

Please, do you have any ideas?

eitsupi commented 1 year ago

@VitorAguiar Is httpgd installed on the R you are connecting to via ssh? What is the path and complete contents of the Rprofile?

In short, you are setting something up wrong.

VitorAguiar commented 1 year ago

Yes, httpgd is installed In the remote machine. My .Rprofile is located in my home directory, and it has nothing but: options(vsc.use_httpgd = TRUE)

VitorAguiar commented 1 year ago

Ah, it works if instead of opening a terminal, I open an R terminal.

Although it still doesn't work if I'm on a Slurm interactive job. In that case, the plots go to a Rplots.pdf file. But that is probably a config issue in the remote server?