WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

options(c("repr.plot.width", "repr.plot.height")) not handled as expected. #59

@dmurdoch

Description

@dmurdoch

This StackOverflow question: https://stackoverflow.com/q/72698223 illustrates what looks like a bug in the display of graphics. This script:

temp <- mtcars[, 1:3]
colnames(temp) <- c("x1", "z", "y1")

plotting_function <- function(data_to_vis) {
  
  p1 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
    geom_point(size = 3)       
  options(repr.plot.width = 5, repr.plot.height = 5)     
  print(p1)
  p2 <- ggplot(data_to_vis, aes(x=x1, y=y1)) +
    geom_point() +
    facet_wrap(~z) +
    theme(aspect.ratio = 1)
  options(repr.plot.width = 20, repr.plot.height = 20) 
  print(p2)
}

library(ggplot2)
plotting_function(temp)

uses the 2nd options() setting to set the width and height of both plots. To get them to appear as intended, the first setting needs to be moved after the print(p1) statement.

This was tested on the R kernel at https://jupyter.org/try, which reports "The version of the notebook server is: 6.4.10", "Current kernel information: R version 4.1.2 (2021-11-01)".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions