2016-11-29 136 views
0

我遇到的問題與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) 

不過,雖然是可以收縮和伸展的情節,底部仍然得到切斷。

任何想法?

回答

0

那麼,經過大量的搜索,仍然無法做到正確。我可以用它代替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)