2016-11-29 2 views
0

나는 주전자의 How can I make my vertical labels fit within my plotting window? 사람과 같은 문제가 있습니다. Jupyter 내의 R에 바 플롯을 만들 때 세로로 긴 x 축 레이블이 잘리지 않습니다. 링크 된 질문 Mac 용 R GUI에서가 아니라 Jupyter에서주피터에서 X 축 레이블이 잘림 R

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) 

작품 솔루션을 사용하여 예를

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

하십시오.

는 또한 예를

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

를 들어,에 repr과 옵션을 가지고 노는 시도했다하지만 그 음모를 축소하고 늘릴 수 있지만, 바닥은 여전히 ​​차단을 가져옵니다.

아이디어가 있으십니까?

답변

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)