【问题标题】:R: vertical x labels out of plotR:图中的垂直x标签
【发布时间】:2014-07-01 13:43:31
【问题描述】:

我有一个情节,我通过las = 2 引入了垂直 x 轴标签。这些标签就是文字。分类词。这些词太长了,超出了图片范围。我的情节中没有主标题(不需要),因此图像顶部有足够的空间。但是我如何改变一切呢?我找到了名为maimar 的参数的代码。但它们并没有改变任何东西。

我尝试通过将mar ("top") 的第三个值设置为 0 来使用 mar。所以我希望顶部的边距为 0。但情节保持原样:/

这是我的代码(x 标签的德语单词):

categories <- c("Introvertiert", "Selbstbewusst", "Kooperativ", "Ehrgeizig", 
"Einfühlsam", "Autoritär", "Temperamentvoll", "Flexibel", "Tolerant", "Teamfähig", 
"Zielorientiert", "Überheblich", "Vielseitig", "Ungeduldig", "Zuverlässig", "Eigensinnig",
 "Anpassungsfähig", "Souverän", "Selbstkritisch", "Entscheidungsfreudig", "Intelligent", 
"Kontaktfreudig", "Kreativ", "Stressresistent", "Hilfsbereit", "Emotional", 
"Kompromissbereit", "Gesellig", "Standhaft", "Pünktlich", "Unruhig", "Tatkräftig",
 "Aufgeschlossen", "Fröhlich", "Zuvorkommend", "Uneigennützig", "Selbstbeherrscht", 
"Schüchtern", "Freundlich", "Sprachgewandt")

x <- seq(1,40)
y <- seq(1,40)

plot(x,y,xaxt="n",main="", mar=c(5, 4, 0, 2) + 0.1, xlab ="")

axis(1, at=1:40, labels=categories, las = 2, cex.axis = 0.8)

【问题讨论】:

    标签: r plot shift


    【解决方案1】:

    使用par:

    #save old settings
    op <- par(no.readonly = TRUE)
    #change settings
    par(mar=c(8, 4, 2, 2) + 0.1)
    plot(x,y,xaxt="n",main="", xlab ="")
    axis(1, at=1:40, labels=categories, las = 2, cex.axis = 0.8)
    #reset settings
    par(op)
    

    【讨论】:

    • 哦,好吧,所以我没有想到错误的方向。我想我可以将 mar 规范插入 plot 命令。谢谢!
    猜你喜欢
    • 2020-09-25
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多