Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Index table beside plot

I am looking for a way to add a table beside a plot (outside of the actual Cartesian canvas). The table would be an index of sort with more information correlating to the labels already on the plot. I have a scatter plot as follows created using ggplot:

enter image description here

The R code for the plot is as follows:

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()

I have a column in my data frame that has the name of the point. So, for example, something long these lines:

1: Name One
2: Name Two
3: Name Three
.
.
.
150: Name 150

How would I go about adding such a table? I don't want to add the whole name in the scatter plot as it would overlap a lot of points. As you can see, even the numbers themselves overlap although it's acceptable.

An inputs are welcome and appreciated.

like image 596
intl Avatar asked Jun 09 '26 21:06

intl


1 Answers

try this for a minimal example:

library(gridExtra)
library(ggplot2)
grid.arrange(qplot(1,1), legend = tableGrob(matrix(1:10, ncol=2)))
like image 160
baptiste Avatar answered Jun 11 '26 22:06

baptiste