代码
#'@导出图片格式教程
#'@20230104
#'#安装相关的包
#'
library(ggplot2)
#BiocManager::install("eoffice")
library(eoffice)
#'@绘图
ggplot(df02[,1:2],aes(x=年龄,fill = Group))+
geom_histogram(,binwidth = 1)+
theme_bw()+scale_y_continuous(expand = c(0,0))+
scale_fill_brewer(palette = "Accent")+
#scale_fill_npg(drop=TRUE)+
ylab("number")+xlab("years")+
ggtitle("this plot title")+
theme(legend.title = element_blank())+
theme(text = element_text(size=12))
#'@输出文件
#'@方法一:使用ggsave()
ggsave("plot01.pdf", width = 4, height = 4)
ggsave("plot02.jpg",width = 4, height = 4)
ggsave("plot03.png",width = 4, height = 4)
ggsave("plot04.tiff",width = 4, height = 4)
##'@输出pptx
topptx(filename = "plot05.pptx")
tohtml(filename = "plot06.html")
输出结果
PPTX格式
图片所有内容可编辑
可输出其他格式的图形
– topptx write figures to powerpoint file.
– todocx write figures to word file.
– totable write data frame or summary results of different model to powerpoint or word files
– indocx read tables from word file
– inpptx read tables from powerpoint file
– tofigure write figures to different output formats.
– tohtml write figures to interactive html file
– infigure read figures or pdf files into R and extract colors from these files.
自己动手试一下吧 !!
小杜的生信筆記 ,主要发表或收录生物信息学的教程,以及基于R的分析和可视化(包括数据分析,图形绘制等);分享感兴趣的文献和学习资料!
网友评论