R -小提琴的地轴名称。

时间:2022-01-18 14:59:34

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:

我正在创作有很多(将会是~100)列(小提琴)的小提琴情节。问题是每一列的名称都很长。我目前的工作如下:

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:

这就给了我这个情节:

R -小提琴的地轴名称。

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:

这就给了我这个情节:

R -小提琴的地轴名称。

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. 列的名称将是垂直的,这样它们就会显示出来,不会被截断。
  3. 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

    1 -非常非常的longname1 2 -非常非常的longname2…8 - veryveryveryverylongname8

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

是否有人建议更好的方法(或两者)并评论如何实现它们?

Greatly appreciated.

大大赞赏。

1 个解决方案

#1


3  

Unfortunately the vioplot function in the vioplot package does not accept the usual base graphics parameters for modifying the orientation of axis annotation. You will need to make a new vioplot function and change this code:

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

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

To this:

:

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

#1


3  

Unfortunately the vioplot function in the vioplot package does not accept the usual base graphics parameters for modifying the orientation of axis annotation. You will need to make a new vioplot function and change this code:

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

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

To this:

:

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