使用R在Jupyter中切断X轴标签

时间:2016-11-29 15:04:38

标签: r plot jupyter

我和来自How can I make my vertical labels fit within my plotting window?的人有同样的问题,但在Jupyter。当我在Jupyter的R中制作一个条形图时,任何长的垂直x轴标签都会被切断。例如

animals = c("dog","cat","squirrel","dog","fox","dog","llama","cat","tyrannosaurus rex")
sorted <- sort(table(animals), decreasing=T)
barplot(sorted, las = 2)

使用解决方案链接问题

animals = c("dog","cat","squirrel","dog","fox","dog","llama","cat","tyrannosaurus rex")
sorted <- sort(table(animals), decreasing=T)
par(mar = c(15,4,4,2) + 0.1) 
barplot(sorted, las = 2)

在R gui中为mac工作但在Jupyter中没有。

我也尝试过使用repr及其选项,例如

library(repr)
options(repr.plot.width=4, repr.plot.height=4)

但是虽然这可以收缩和拉伸情节,但底部仍然会被切断。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

嗯,经过大量的搜索,仍然无法做到正确。我能够让它与ggplot一起工作

r1