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

treemap should not creates viewport if draw = FALSE #58

Open
mcanouil opened this issue Oct 15, 2024 · 0 comments
Open

treemap should not creates viewport if draw = FALSE #58

mcanouil opened this issue Oct 15, 2024 · 0 comments

Comments

@mcanouil
Copy link

mcanouil commented Oct 15, 2024

Thanks for developing this R package!

Currently treemap::treemap opens a new grid viewport by default and does not respect draw = FALSE.
If draw = FALSE, no graphics device should be open.

To cleanly embed treemap() function into other code/function, you have to make ugly things like the code below which is not ideal.

library(treemap)
data(GNI2014)

grDevices::pdf(file = "/dev/null")
treemap(
  dtf = GNI2014,
  index = c("continent", "iso3"),
  vSize = "population",
  vColor = "GNI",
  type = "value",
  format.legend = list(scientific = FALSE, big.mark = " "),
  draw = FALSE
)
invisible(grDevices::dev.off())

For short, all viewports functions should be conditional on draw.

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

1 participant