cowplot的很多功能实现就依赖于gtable。 最近探索了一下gtable的使用,主要是两个方面:如何进行拼图和嵌图。 gtable进行拼图 如果要使用gtable进行拼图,只需要创建一个1行2列的gtable对象,然后每个位置填入相应的图像即可。 填充图形是使用的gtable_add_grob实现的。 (p2)) # 创建一个布局为一行两列的gtable对象,用于放置上述的两个对象 # 每一个位置的长宽都是1 null fig_combined <- gtable(widths = unit(c(1 , 1), "null"), heights = unit(1, "null")) # 将两张图片分别放入gtable中 # gtable_add_grob gtable进行嵌图 gtable也可以进行嵌图,思路和拼图是一样的,先构造一个新gtable布局,然后将图片依次嵌入。
library(patchwork) pdf(file="Rplot05.pdf", width = 9.4, height = 4) wrap_elements(ggmatrix_gtable (pc.pr))+ wrap_elements(ggmatrix_gtable(p2)) dev.off() image.png 新知识点:ggpairs()函数作图后的拼图代码wrap_elements (ggmatrix_gtable(pc.pr))+ wrap_elements(ggmatrix_gtable(p2)) 参考链接 https://github.com/thomasp85/patchwork
typedef unsigned char UINT8; typedef unsigned int UINT32; static UINT8 RTable[256][256]; static UINT8 GTable = y - 0.34414 *(u - 128) - 0.71414 * (v - 128); //g if (res > 255) res = 255; if (res < 0) res = 0; GTable rgb_index]; u = yuyv[nv_start + nv_index]; v = yuyv[nv_start + nv_index + 1]; r = RTable[y][v]; g = GTable rgb_index]; u = yuyv[nv_start + nv_index]; v = yuyv[nv_start + nv_index + 1]; r = RTable[y][v]; g = GTable
0x01正文 先去查壳一下,发现是64位无壳ELF文件 可以发现,该程序是通过 for ( i = 0; i <= 4; ++i ) { v3 = gtable(); 进入gtable()来看看变表生成逻辑 从上图可知。
---背景SQL-1:select a.name from tabler a Left Join gtable1 b on a.name = b.name and a.id = 2; (tabler、gtable1 tabler.id 为分片列;两个表配置的节点均为dn1~4)查看 SQL-1 在 DBLE 中执行计划 Explain-1:图片从explain中,将分片表 tabler 分别下发各个节点,全局表 gtable1 提出Suppose-1SQL-1 on中 “a.id = 2”,a.id作为分片列; 看起来可以根据a.id明确路由单节点下发tabler表,然后gtable1作为全局表可以随意选一个路由节点下发;具体假设 SQL-2:select a.name from tabler a Left Join gtable1 b on a.name = b.name where a.id = 2;提出的Suppose-1
#include <ntifs.h> typedef struct _AAA { int id; int y; int x; }AAA,*PAAA; RTL_GENERIC_TABLE gTABLE (&gTABLE, &aaa2, sizeof(AAA), &newE); RtlInsertElementGenericTable(&gTABLE, &aaa3, sizeof(AAA), &newE ); AAA node = {3,0,0}; //查找 AAA * xxx = RtlLookupElementGenericTable(&gTABLE, &node); //获取元素个数 RtlIsGenericTableEmpty(&gTABLE)) { //遍历 for (xx = RtlEnumerateGenericTableWithoutSplaying(&gTABLE = NULL; xx = RtlEnumerateGenericTableWithoutSplaying(&gTABLE, &RestartKey)) { DbgPrintEx(77,
ggplot2", # quietly = TRUE), list(), getNamespace("ggplot2")) # data <- ggplot_build(x) # gtable <- ggplot_gtable(data) # if (is.null(vp)) { # grid.draw(gtable) # } # else { # (is.character(vp)) # seekViewport(vp) # else pushViewport(vp) # grid.draw(gtable
kept labels ## repel.degree = 1: spread out labels over the full y-axis heatmap <- pheatmap$gtable = ""] <- new.y.positions # add flag to heatmap heatmap <- gtable::gtable_add_grob(x = heatmap,
breaks = seq(-3,3,length.out = 100) ) heatmap_plot 拼图 library(patchwork) volcano_plot +heatmap_plot$gtable recordPlot() 拼图 load("pca_plot.Rdata") plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable ) dev.off() 保存 pdf("deg.pdf") plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable
ggplot对象的渲染过程 一个ggplot2的渲染过程分为两步: (1)ggplot_build函数将ggplot对象进行各种数据和坐标变换,生成一个ggplot_build对象; (2)ggplot_gtable 函数以ggplot_build对象为输入进行下一步的绘图对象生成的工作,最后返回一个gtable对象。 gtable就是一个可以直接渲染的图形对象了。 Geom: 在ggplot_gtable的第一个环节就是调用layer的draw_geom函数,draw_geom调用每个layer的draw_layer函数完成grob对象创建、 其他从略 简单来说就是 在ggplot_gtable的第一个环节就是调用Geom的图形对象绘制函数生成grob对象。 所以一个图层的Stat和Geom其实是分别用于数据变换和图形绘制。
cluster_cols = F, show_rownames = T, show_colnames = F) p3 library(cowplot) plot_grid(p1$gtable , p2$gtable, p3$gtable,nrow = 1, labels=c('ubiquitous_genes',
.- attr(*, "class")= chr "hclust" ## $ kmeans : logi NA ## $ gtable :List of 6 ## ..$ grobs ..$ respect : logi FALSE ## ..$ rownames : NULL ## ..- attr(*, "class")= chr [1:4] "gtable
# plot dat_1, dat_2 cowplot::plot_grid( pheatmap::pheatmap(dat_1, main = "dat_1", silent = T)$gtable , pheatmap::pheatmap(dat_2, main = "dat_2", silent = T)$gtable ) 模拟数据展示 模拟数据如下图所示,而我们想要的效果是合并这两个热图
(-3,3,length.out = 100) ) heatmap_plot #拼图 library(patchwork) volcano_plot +heatmap_plot$gtable pca_plot.Rdata") library(patchwork) plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable dev.off() #保存 pdf("deg.pdf") plot_grid(pca_plot,corr_plot, volcano_plot,heatmap_plot$gtable
‘viridisLite’, ‘ellipsis’, ‘fansi’, ‘magrittr’, ‘pillar’, ‘pkgconfig’, ‘vctrs’, ‘digest’, ‘glue’, ‘gtable 173672 bytes (169 KB) downloaded 169 KB 试开URL’https://cloud.r-project.org/bin/windows/contrib/4.1/gtable successfully unpacked and MD5 sums checked package ‘glue’ successfully unpacked and MD5 sums checked package ‘gtable
=TRUE) > p2<-pheatmap(d2,color=Color,breaks=breaks,border_color="black",legend=TRUE) >plot_grid(p1$gtable ,p2$gtable,align='vh',labels=c("A","B"),ncol=2) ?
breaks = seq(-3,3,length.out = 100)) heatmap_plot#拼图library(patchwork)volcano_plot +heatmap_plot$gtable recordPlot() # 拼图load("pca_plot.Rdata")plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable )dev.off()#保存pdf("deg.pdf")plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable)dev.off
breaks = seq(-3,3,length.out = 100)) heatmap_plot拼图library(patchwork)volcano_plot +heatmap_plot$gtable 只有当画图框里有图才能被记录拼图load("pca_plot.Rdata")plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable )dev.off()保存pdf("deg.pdf")plot_grid(pca_plot,cor_plot, volcano_plot,heatmap_plot$gtable)dev.off
param name="rowIndex"></param>
/// <returns></returns>
DataRow this[int rowIndex] { get; }
}
GTable 定义如下:
///
p1 + ggtitle('Look at me shrink')) ###对齐子图 p6<- ggplot(mtcars) + geom_point(aes(mpg, disp)) library(gtable