Skip to content

"Copy as metafile" in Rgui, as well as default ggsave(), scale the whole figure to the top left quarter #6349

Closed as not planned
@telenskyt

Description

@telenskyt

I have exactly the same problem as reported here, not sure why that one was closed.

When I produce ggplot2 and then right click the chart and select "Copy as metafile" (in the standard Rgui in Windows), it scales the whole figure just in the top left quarter like this:

Image

  1. In the Rgui, everything looks alright.
  2. I get the same faulty result when I do ggsave("cover.wmf").

Reproducible code:

cover <- structure(list(scen = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 
5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 
10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 
12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 
14L, 15L, 15L, 15L, 15L, 15L, 15L), n = c(20, 20, 20, 20, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
20, 20, 20, 20, 20), r = c(0, 0, 0, 0, 0, 0, 0.2, 0.2, 0.2, 0.2, 
0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.6, 0.6, 0.6, 0.6, 0.6, 
0.6, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0, 0, 0, 0, 0, 0, 0.2, 0.2, 
0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.6, 0.6, 0.6, 
0.6, 0.6, 0.6, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0, 0, 0, 0, 0, 0, 
0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.6, 
0.6, 0.6, 0.6, 0.6, 0.6, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8), n_ind = c(40, 
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 160, 160, 
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 
160, 160, 640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 
640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 640, 
640, 640, 640, 640, 640, 640), method = structure(c(3L, 4L, 5L, 
2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 
4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 
1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 
2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 
4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 1L, 3L, 4L, 5L, 2L, 6L, 
1L, 3L, 4L, 5L, 2L, 6L, 1L), levels = c("true", "ignore", "BPA2012", 
"corrected(1)", "corrected(100)", "model_est"), class = "factor"), 
    cover_count = c(3243L, 4916L, 4918L, 4772L, 4825L, 4769L, 
    3266L, 4918L, 4919L, 4751L, 4810L, 4774L, 3341L, 4886L, 4886L, 
    4733L, 4821L, 4751L, 3134L, 4798L, 4794L, 4687L, 4816L, 4783L, 
    2030L, 4285L, 4279L, 4298L, 4828L, 4745L, 1859L, 4810L, 4809L, 
    4733L, 4805L, 4722L, 1896L, 4822L, 4820L, 4739L, 4817L, 4747L, 
    2041L, 4821L, 4825L, 4744L, 4803L, 4737L, 2284L, 4827L, 4826L, 
    4752L, 4815L, 4756L, 2760L, 4806L, 4808L, 4773L, 4835L, 4758L, 
    959L, 4740L, 4739L, 4719L, 4796L, 4721L, 976L, 4754L, 4761L, 
    4738L, 4805L, 4734L, 1101L, 4755L, 4759L, 4732L, 4793L, 4728L, 
    1202L, 4795L, 4796L, 4772L, 4820L, 4765L, 1610L, 4842L, 4840L, 
    4788L, 4835L, 4758L), cover = c(0.6486, 0.9832, 0.9836, 0.9544, 
    0.965, 0.9538, 0.6532, 0.9836, 0.9838, 0.9502, 0.962, 0.9548, 
    0.6682, 0.9772, 0.9772, 0.9466, 0.9642, 0.9502, 0.6268, 0.9596, 
    0.9588, 0.9374, 0.9632, 0.9566, 0.406, 0.857, 0.8558, 0.8596, 
    0.9656, 0.949, 0.3718, 0.962, 0.9618, 0.9466, 0.961, 0.9444, 
    0.3792, 0.9644, 0.964, 0.9478, 0.9634, 0.9494, 0.4082, 0.9642, 
    0.965, 0.9488, 0.9606, 0.9474, 0.4568, 0.9654, 0.9652, 0.9504, 
    0.963, 0.9512, 0.552, 0.9612, 0.9616, 0.9546, 0.967, 0.9516, 
    0.1918, 0.948, 0.9478, 0.9438, 0.9592, 0.9442, 0.1952, 0.9508, 
    0.9522, 0.9476, 0.961, 0.9468, 0.2202, 0.951, 0.9518, 0.9464, 
    0.9586, 0.9456, 0.2404, 0.959, 0.9592, 0.9544, 0.964, 0.953, 
    0.322, 0.9684, 0.968, 0.9576, 0.967, 0.9516)), row.names = c(NA, 
-90L), class = "data.frame")


library(ggplot2)

ggplot(cover, aes(x = r, y = cover)) + ylab("coverage (95% CI)") + 
	geom_hline(yintercept = 0.95) + 
	geom_point(color = "#00B937")

ggplot2 version 3.5.1 in R 4.4.1

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