簡體   English   中英

在並排條形圖上調整 y 軸刻度和 x 軸

[英]adjusting y-axis scale and x-axis on side by side barchart

我使用以下代碼生成並排條形圖

IT=c(0.588, 0.765)
GE=c(0.214, 0.63)
FR=c(0.316, 0.356)
PO=c(0.692,0.793)
UK=c(0.381, 0.757)
NE=c(0.227, 0.62)
GR=c(0.692, 0.902)
HU=c(0.706, 0.698)
SW=c(0.143, 0.493)

# combine two vectors using cbind 
# function
CountryChart=cbind(IT,GE,FR,PO,UK,NE,GR,HU,SW)

# pass this college_data to the 
# barplot
barplot(CountryChart,beside=T) 

它會生成一個包含正確數據的圖表,但是 y 軸太短,因為它只從 0 到 0.8 而不是 1。國家/地區標簽也沒有全部顯示在 x 軸上。 只顯示四個國家代碼,所以我想調整代碼,以便在其條形下方顯示每個國家的代碼。

這是我能夠生成的圖表:

在此處輸入圖像描述

關於如何調整 y 軸的比例大小並在 x 軸上顯示所有國家代碼的任何想法?

要將 y 軸從 go 變為 1,請在barplot調用中添加ylim = c(0, 1)

barplot(CountryChart,beside=T, ylim = c(0, 1)) 

在此處輸入圖像描述

要使您所有的國家都出現在 x 軸上,您需要意識到 plot 正在抑制一些標簽以防止它們重疊。 要解決此問題,您可以縮小 x label 尺寸:

barplot(CountryChart,beside=T, ylim = c(0, 1), cex.names = 0.75) 

在此處輸入圖像描述

或者簡單地拖動繪圖 window 使其變寬:

barplot(CountryChart,beside=T, ylim = c(0, 1)) 

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM