1

I am creating violin plots with lots (will be ~100) of columns (violins). The problem is that the name of each column is very long. What I am doing current is as follows:

jpeg("stats/AllDistanceViolinPlot.jpg", width = 1000, height = 1000);
do.call(vioplot, c(lapply(data, na.omit),list(names=c("veryveryveryverylongname1", "veryveryveryverylongname2", "veryveryveryverylongname4", "veryveryveryverylongname4", "veryveryveryverylongname5", "veryveryveryverylongname6", "veryveryveryverylongname7", "veryveryveryverylongname8"))));
dev.off()

Which gives me this plot:

enter image description here

As you can see, the names of the columns are very long and some actually are not shown. I have also tried something without the list:

jpeg("stats/plot.jpg", width = 1000, height = 1000);
do.call(vioplot, c(lapply(data, na.omit)));
dev.off()

Which gives me this plot:

enter image description here

What I'd like is one of two things:

  1. The names of the columns would be vertical so that they are shown and aren't cut off or
  2. Make the main plot like the second image I posted and have a separate legend that would correlate each column with the full name. For example, something like the following:

    1 - veryveryveryverylongname1 2 - veryveryveryverylongname2 ... 8 - veryveryveryverylongname8

Could someone please suggest the better way (or both) and comment on how to implement them?

Greatly appreciated.

4

1 回答 1

3

不幸的是,vioplot 包中的 vioplot 函数不接受用于修改轴注释方向的常用基本图形参数。您将需要创建一个新的 vioplot 函数并更改此代码:

if (!horizontal) {
    if (!add) {
        plot.window(xlim = xlim, ylim = ylim)
        axis(2)
        axis(1, at = at, label = label)

对此:

if (!horizontal) {
    if (!add) {
        plot.window(xlim = xlim, ylim = ylim)
        axis(2)
        axis(1, at = at, label = label , las=2)
于 2013-07-22T17:52:03.990 回答