Home > Mobile >  How to save a picture with very long height
How to save a picture with very long height

Time:10-27

I have one figure showing plant phylogenetic tree (visualized in R) and it contains so many species. So far, when I save it as pdf or png, 1 page is not enough for me/people who want to read the result. Can I ask for how do you guy can save it in 2 pages and more. Or how to extend the page size since the maximum is 55 cm. Any sugesstions for this?

The thing that I want as picture below.

enter image description here

CodePudding user response:

You can save 'longer' figures with png and pdf, e.g.

#remotes::install_github("allisonhorst/palmerpenguins")
library(palmerpenguins)
library(tidyverse)

png("test.png", width = 10, height = 200, units = "cm", res = 96)
ggplot(data = subset(penguins, !is.na(sex)),
       aes(x = island, fill = sex))  
  geom_bar(width = 0.5)  
  geom_text(stat='count', aes(label=..count..),
            position = position_stack(vjust = 0.5))  
  theme(axis.text.x = element_text(angle = 65, vjust= 0.6))  
  labs(title = "All Accessible Penguin Sex Count",
       x = "island",
       y = "Number of Individuals",
       fill = "Sex")
dev.off()
#> quartz_off_screen 
#>                 2

example_1.png

Created on 2021-10-27 by the reprex package (v2.0.1)

--

And, for pdf:

pdf("test.pdf", width = 10, height = 200)
ggplot(data = subset(penguins, !is.na(sex)),
       aes(x = island, fill = sex))  
  geom_bar(width = 0.5)  
  geom_text(stat='count', aes(label=..count..),
            position = position_stack(vjust = 0.5))  
  theme(axis.text.x = element_text(angle = 65, vjust= 0.6))  
  labs(title = "All Accessible Penguin Sex Count",
       x = "island",
       y = "Number of Individuals",
       fill = "Sex")
dev.off()

(I can't upload the pdf to stackoverflow, but the code worked on my system)

  •  Tags:  
  • r
  • Related