Reputation: 855
I wanted to ask for any general idea about plotting this kind of plot in R which can compare for example the overlaps of different methods listed on the horizontal and vertical side of the plot? Any sample code or something
Many thanks
Upvotes: 1
Views: 564
Reputation: 49640
The corrplot package and corrplot
function in that package will create plots similar to what you show above, that may do what you want or give you a starting point.
If you want more control then you could plot the colors using the image
function, then use the text
function to add the numbers. You can either create the margins large enough to place the text in the margins, see the axis
function for the common way to add text labels in the margin. Or you could leave enough space internally (maybe use rasterImage
instead of image
) and use text
to do the labelling. Look at the xpd
argument to par
if you want to add the lines and the grconvertX
and grconvertY
functions to help with the coordinates of the line segents.
Upvotes: 1
Reputation: 13280
A ggplot2-example:
# data generation
df <- matrix(runif(25), nrow = 5)
# bring data to long format
require(reshape2)
dfm <- melt(df)
# plot
require(ggplot2)
ggplot(dfm, aes(x = Var1, y = Var2)) +
geom_tile(aes(fill = value)) +
geom_text(aes(label = round(value, 2)))
Upvotes: 3