Resizing agreementplot from "vcd" library in R

161 views Asked by At

I am new to R. I am trying to make a nice agreementplot from vcd package, but I have no idea how to resize it. The labels remain too crowded. My code is: p <- agreementplot(ctable)
Done with this tutorial: https://www.datanovia.com/en/lessons/inter-rater-agreement-chart-in-r/
Source code for plot: https://github.com/TypeFox/R-Examples/blob/d0917dbaf698cb8bc0789db0c3ab07453016eab9/vcd/R/agreementplot.R
Would also be grateful for tips on how to rename axes of this plot, cheers!

Plot

1

There are 1 answers

0
user12728748 On BEST ANSWER

The labels on the axes should correspond to names(dimnames(ctable)), so try changing those.

To have more space it might help if you increase the size of your output device, since font sizes are hard-coded in the agreementplot function you linked to. So if you output to png, try increasing width and height, for example. If you are using RStudio, you can change the size of the plot window and/or the export preview window to see how that affects the relative sizes and whether that can give you something you are happy with.

Alternatively, you could modify the agreementplot function if you want to adjust some of the hard-coded values, such as font sizes and offset of axis labels. It might help if you rotated the labels using e.g. ylab_rot = 0, ylab_just = "right" (which you could do without modifying the function), but you also may have to change the x value in the line grid.text(ylab, x = -0.1, gp = gpar(fontsize = 20), rot = 90) to something smaller (e.g. 0.3, depending on your labels to make it look decent).