source("pca_and_ggplot2.R") library(ggplot2) library(ggpubr) library(cowplot) pca.ncg<-.pca(data = iris[,1:4], is.log = FALSE) .scatter.density.pc(pcs = pca.ncg$sing.val$v[, 1:3], pc.var = pca.ncg$variation, strokeColor = 'gray30', strokeSize = .2, pointSize = 2, ...
library(ggplot2)library(patchwork)p3<-ggplot(mpg)+geom_boxplot(aes(manufacturer,hwy))+facet_grid(year~.)+coord_flip()p1+p2+p3 image.png 除此之外,如果横向添加四张图,patch 会自动调整图的位置。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 p4<-ggplot(mpg)+geom_tile(aes(factor(cyl),d...
ybp <- ggboxplot(iris$Sepal.Width, width = 0.3, fill="lightgray")+theme_transparent()# Create the external graphical objects# called a "grop" in Grid terminologyxbp_grob <- ggplotGrob(xbp) ybp_grob <- ggplotGrob(ybp)#place box plots inside the scatter plotxmin <- min(iris$Sepal.Leng...
ggplot(plot_data,aes(x = Category, y = Description)) +geom_point(aes(size = Count,color= log_p)) +scale_color_gradientn(colors =c("blue","yellow","red")) +scale_size(range =c(3,10)) +theme_bw(base_size =12) +labs(x ="", y ="", color ="-log10(p-value)", size =...
R语言ggplot2画带有空白格的热图简单小例子 接下来是准备分组颜色条的数据 image.png 下面是画这个颜色条 df2<-read.csv("example_data/ggplot2_heatmap_color_bar.csv",header=T)df2$y<-factor(df2$y,levels = rev(df2$y))ggplot(df2,aes(x=x,y=y))+ geom_tile(aes(fill=group))+ scale_x_contin...
p0 <- ggplot(df, aes(x, y1)) + geom_point() p1 <- ggdraw() + draw_image(logo_file) logo_file <- system.file("extdata", "logo.png", package = "cowplot") p2 <- ggdraw() + draw_plot(p0) + draw_image(logo_file, scale = .5,x = .3,y = 0) ...
library(ggplot2) ggplot(df1.1,aes(x=variable,y=GO_term))+ geom_tile(aes(fill=value)) 1. 2. 3. 4. 5. 6. 7. 8. 9. image.png 接下来是美化 ggplot(df1.1,aes(x=variable,y=GO_term))+ geom_tile(aes(fill=value),color="grey")+ ...
image.png 下面是画这个颜色条 df2<-read.csv("example_data/ggplot2_heatmap_color_bar.csv",header=T) df2$y<-factor(df2$y,levels = rev(df2$y)) ggplot(df2,aes(x=x,y=y))+ geom_tile(aes(fill=group))+ scale_x_continuous(expand = c(0,0))+ ...
另一种选择是将注解创建为一个单独的图,然后用另一个包覆盖它们(cowplot确实很适合,但拼凑也可以)...
此部分只了解两个内容,一是R自带的plot函数画图,二是ggplot2函数 plot函数 R自带的画图工具,R绘图基础图形系统的核心 plot()函数,plot 是一个泛型函数,使用plot 时真正被调用的时函数依赖于对象所属的类。 plot(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,log = "", main = NULL, sub...