Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 绘图旁的索引表_R_Graph_Plot_Data.table - Fatal编程技术网

R 绘图旁的索引表

R 绘图旁的索引表,r,graph,plot,data.table,R,Graph,Plot,Data.table,我正在寻找一种在绘图旁边添加表的方法(在实际的笛卡尔画布之外)。该表将是一个排序索引,其中包含与绘图上已有标签相关的更多信息。我使用ggplot创建了如下散点图: 绘图的R代码如下所示: png("image.png", width = 2000, height = 1500, res = 85); ggplotXY <- ggplot(scatterPlotData, aes(x=x, y=y, colour=labels, label=labels)) + geom_point()

我正在寻找一种在绘图旁边添加表的方法(在实际的笛卡尔画布之外)。该表将是一个排序索引,其中包含与绘图上已有标签相关的更多信息。我使用ggplot创建了如下散点图:

绘图的R代码如下所示:

png("image.png", width = 2000, height = 1500, res = 85);
ggplotXY <- ggplot(scatterPlotData, aes(x=x, y=y, colour=labels, label=labels)) +
geom_point() +
geom_text(hjust=0, vjust=0)
ggplotXY
dev.off()
我将如何添加这样一个表?我不想在散点图中添加全名,因为它会重叠很多点。正如您所看到的,即使数字本身也重叠,尽管这是可以接受的


欢迎并感谢您的输入。

请尝试以下示例:

library(gridExtra)
library(ggplot2)
grid.arrange(qplot(1,1), legend = tableGrob(matrix(1:10, ncol=2)))
library(gridExtra)
library(ggplot2)
grid.arrange(qplot(1,1), legend = tableGrob(matrix(1:10, ncol=2)))