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

Reset par on clear #15

Closed
renkun-ken opened this issue Jun 7, 2020 · 4 comments
Closed

Reset par on clear #15

renkun-ken opened this issue Jun 7, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@renkun-ken
Copy link
Contributor

Does it make sense to reset par on clear (RStudio behavior)?

For, example, the following code uses par() before plot.

httpgd::httpgd()
utils::browseURL(httpgd::httpgdURL())
par(mfrow = c(2, 2))
m <- lm(mpg ~ cyl, data = mtcars)
plot(m)

Then if users clicks Clear button, then the plot is gone.

The difference appears when user then creates a new simple plot:

plot(rnorm(100))

In RStudio, when the plot is all cleared, the par is reset too so that a new plot will revert to par(mfrow = c(1, 1)). In httpgd at the moment, it is not reverted to default par.

I'm wondering which makes more sense?

@nx10
Copy link
Owner

nx10 commented Jun 7, 2020

The "clean" button in RStudio kills the graphics device which results in par being reset.
This seems to be the recommended way of resetting par (https://stackoverflow.com/questions/5789982/reset-par-to-the-default-values-at-startup).
In httpgd this would mean that the webserver had to be shut down and restarted, which I think we should avoid.
Do you shink we should make a copy of the par arguments as suggested by the second answer of the stackoverflow link:

opar <- par() # on startup
# ...
par(opar) # on "clean"

Or is resetting the mfrow argument after clean sufficient?

par(mfrow = c(1, 1))

I am not exactly sure what other settings of par are commonly used.

@nx10 nx10 added the enhancement New feature or request label Jun 7, 2020
@MrJGao
Copy link

MrJGao commented Dec 1, 2021

This is an old session, but I do think it's more convenient if there's a button or command to reset the par. Is it possible to save a default par object when startup and add a button on the toolbar of the plot window to reset par? if that's easier than killing the server and restarting it. Thanks.

@nx10 nx10 mentioned this issue Dec 1, 2021
4 tasks
@nx10
Copy link
Owner

nx10 commented Dec 1, 2021

Thank you for your request, I agree and have added it to the 1.3 tracking issue.

@nx10 nx10 mentioned this issue Dec 4, 2021
@nx10 nx10 closed this as completed in e77d0d7 Feb 28, 2022
@nx10
Copy link
Owner

nx10 commented Feb 28, 2022

Thank you for waiting patiently. I just added a parameter

hgd(
  ... ,
  reset_par = getOption("httpgd.reset_par", FALSE)
)

that toggles this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants