question about save to image
Closed this issue · 4 comments
I use above code to save to image file xx.png
,
library(ggmsa)
png('xx.png')
protein_sequences <- system.file("extdata", "sample.fasta", package = "ggmsa")
ggmsa(protein_sequences, start = 221, end = 280, char_width = 0.5, seq_name = TRUE) + geom_seqlogo() + geom_msaBar()
dev.off()
and I get wired width image as below:
So how I adjust the proper image width or autoadjust it ?
My environment is as this:
R version 4.1.1
ggmsa 1.0.2
Ubuntu 18.04.4 LTS
Thanks!
Si
Hi, Si
ggsave
can help you adjust the image to the right size.
library(ggmsa)
fasta <- system.file("extdata", "sample.fasta", package = "ggmsa")
p <- ggmsa(fasta, 164, 213, color="Chemistry_AA")
library(ggplot2)
ggsave(filename = "p.png", plot = p, height = 5, width = 13)
Regards,
Lang
library(ggplot2)
Thanks for let me known me know the ggsave
! I am not familiar with ggplot or ggsave. Above code can sove my problem, but I am not sure how to set the proper height and width of p.png
. When I not set specific width and height for ggsave, I got a image of 2100x2100.
Hi, Si
ggsave
can help you adjust the image to the right size.library(ggmsa) fasta <- system.file("extdata", "sample.fasta", package = "ggmsa") p <- ggmsa(fasta, 164, 213, color="Chemistry_AA") library(ggplot2) ggsave(filename = "p.png", plot = p, height = 5, width = 13)
Regards, Lang
And add ggsave(filename = "p.png", plot = p, height = 5, width = 13)
to README.md will helpful for ggplot2 newbie like me~
Above code can sove my problem, but I am not sure how to set the proper height and width of p.png
In general, I would choose width and height between1
and 15
.
This requires you to adjust several times according to the actual output.
And add ggsave(filename = "p.png", plot = p, height = 5, width = 13) to README.md will helpful for ggplot2 newbie like me~
nice advice!
Thanks,
Lang