在Jupyter R中切断X轴标签

问题描述:

我遇到的问题与How can I make my vertical labels fit within my plotting window?中的人相同,但在Jupyter中。当我在Jupyter内的R上制作一张barplot时,任何长的垂直x轴标签都会被切断。例如在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贵为Mac而不是在Jupyter。

我也试图与再版及其选项打,例如

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

不过,虽然是可以收缩和伸展的情节,底部仍然得到切断。

任何想法?

那么,经过大量的搜索,仍然无法做到正确。我可以用它代替ggplot

library(ggplot2) 
animals = c("dog","cat","squirrel","dog","fox","dog","llama","cat","tyrannosaurus rex") 
bars<- ggplot()+ 
    aes(x=animals)+ 
    geom_bar(stat="count")+ 
    theme(axis.text.x = element_text(angle = 90, hjust = 1)) 
print(bars)