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

`dev.new` doesn't work as expected on OSX & Ubuntu #116

Closed
achubaty opened this Issue Jan 9, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@achubaty
Contributor

achubaty commented Jan 9, 2015

Using dev.new(noRStudioGD=TRUE) in RStudio on OSX and Ubuntu opens a new pdf device (named Rplots.pdf) rather than opening a new quartz or x11 window.

Update 2015-06-12: I emailed r-package-devel list about this and have received one reply so far, which was also cc'ed to RStudio. We'll wait for a few days before following up with my maybe-solution below.

@achubaty achubaty modified the milestone: v0.5.0 Jan 9, 2015

@eliotmcintire

This comment has been minimized.

Contributor

eliotmcintire commented Mar 24, 2015

small bug fix with dev() with no argument. Wouldn't work if a previous plot had been closed. cde8027

@eliotmcintire eliotmcintire added the Plot label Jun 11, 2015

@achubaty

This comment has been minimized.

Contributor

achubaty commented Jun 13, 2015

A user-invoked workaround is to set the device manually via options. We could wrap something like the following:

# set default graphics device (required for RStudio)
# based on answer here: http://ow.ly/OhgIQ
setDevice <- function() {
   options(spades.device = getOption("device"))  # move this line to `.onLoad`
   if (getOption("device")=="RStudioGD") {
     if (Sys.info()["sysname"]=="Darwin") {
       options(device="quartz")
     } else if (Sys.info()["sysname"]=="Linux") {
       options(device="x11")
     } else if (Sys.info()["sysname"]=="Windows") {
       options(device="windows") # `dev.new` works on Windows, so could omit this
     }
   }
  message("Default plot device set to ", getOption("device"), ". ",
          "Remember to reset your default device using `unsetDevice()`.")
}

# unset default graphics device (i.e., return to user's prev setting). call during `.onUnload`?
unsetDevice <- function() {
  if (!is.null(getOption("spades.device"))) {
    options(device=getOption("spades.device"))
  }
  options(spades.device = NULL)
}

Cannot use setDevice in .onLoad (needs to be run by the user in the RStudio console), but may be able to unset during .onUnload.

Could we somehow use setHook to trigger the option being set automatically so the user doesn't have to manually do this?

@eliotmcintire

This comment has been minimized.

Contributor

eliotmcintire commented Jun 14, 2015

I think this is as good as any other option. The good side is that the
silly rstudio plot device will just be ignored, like it should be.

On Sat, Jun 13, 2015, 2:17 PM Alex Chubaty notifications@github.com wrote:

A user-invoked workaround is to set the device manually via options. We
could wrap something like the following:

set default graphics device (required for RStudio)# based on answer here: http://ow.ly/OhgIQsetDevice <- function() {

options(spades.device = getOption("device"))
if (getOption("device")=="RStudioGD") {
if (Sys.info()["sysname"]=="Darwin") {
options(device="quartz")
} else if (Sys.info()["sysname"]=="Linux") {
options(device="x11")
} else if (Sys.info()["sysname"]=="Windows") {
options(device="windows")
}
}
message("Default plot device set to ", getOption("device"), ". ",
"Remember to reset your default device using unsetDevice().")
}

unset default graphics device (i.e., return to user's prev setting)unsetDevice <- function() {

if (!is.null(getOption("spades.device"))) {
options(device=getOption("spades.device"))
}
options(spades.device = NULL)
}

Cannot use setDevice in .onLoad (needs to be run by the user in the
RStudio console), but may be able to unset during .onUnload.


Reply to this email directly or view it on GitHub
#116 (comment)
.

@achubaty

This comment has been minimized.

Contributor

achubaty commented Jun 15, 2015

From JJ Allaire at RStudio: fix committed in RStudio dailies; will appear in a few weeks in a minor update. Closing this now.

@achubaty

This comment has been minimized.

Contributor

achubaty commented Nov 28, 2016

Although resolved on macOS, this RStudio bug is still present in the RStudio v1.0.44 for Debian/Ubuntu.

achubaty added a commit that referenced this issue Nov 28, 2016

workaround for dev.new problems (#116)
- reverts a216eee, which triggers NOTE in R CMD check
- instead, set the default graphics device via the`device` option

achubaty added a commit that referenced this issue Nov 28, 2016

workaround for dev.new problems (#116)
- reverts a216eee, which triggers NOTE in R CMD check
- instead, set the default graphics device via the`device` option

achubaty added a commit that referenced this issue Nov 28, 2016

achubaty added a commit that referenced this issue Nov 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment