[英]Adjust bean plot and legend in R
我有關於我的豆圖和傳說的問題。 我找不到追蹤的方法
communication_focused
更改為communication-focused
) mean
(每個類別中的黑色實線) 這是我的代碼:
beanplot(onset_s~ group*meaning, data=mu3,ll = 0.08,
main = "Distribution of movement units", side = "both",
col = list("black", c("grey", "white")),
axes=T, beanlines = "median")
legend("topleft",fill = c("grey", "black"), legend = c("Non-Performers", "Experts"), cex=0.65)
我的數據集:
tier meaning onset_sgroup
head_face_mu self_focused 0 expert
head_face_mu self_focused 0 expert
head_face_mu context_focused 0 expert
upper_body_mu self_focused 0 expert
upper_body_mu self_focused 0 expert
head_face_mu communication_focused 0 novice
head_face_mu context_focused 0 novice
head_face_mu context_focused 0 novice
upper_body_mu self_focused 0 novice
upper_body_mu self_focused 0 novice
upper_body_mu self_focused 0 novice
head_face_mu self_focused 0.18 novice
lower_body_mu self_focused 0.667 novice
head_face_mu communication_focused 0.69 novice
head_face_mu context_focused 1.139 novice
head_face_mu context_focused 1.301 novice
head_face_mu context_focused 1.32 novice
lower_body_mu self_focused 1.66 novice
head_face_mu context_focused 1.98 novice
lower_body_mu self_focused 2.205 novice
head_face_mu communication_focused 2.297 novice
head_face_mu context_focused 2.349 novice
lower_body_mu self_focused 2.417 novice
upper_body_mu self_focused 2.666 novice
head_face_mu self_focused 2.675 expert
head_face_mu context_focused 3.218 novice
head_face_mu context_focused 3.353 novice
head_face_mu context_focused 3.436 expert
head_face_mu context_focused 3.588 novice
head_face_mu context_focused 3.697 novice
upper_body_mu self_focused 4.006 novice
upper_body_mu context_focused 4.033 novice
upper_body_mu self_focused 4.06 expert
head_face_mu context_focused 4.33 novice
upper_body_mu self_focused 4.332 novice
upper_body_mu self_focused 4.44 novice
head_face_mu context_focused 4.738 novice
lower_body_mu self_focused 5.395 novice
head_face_mu self_focused 5.428 novice
lower_body_mu self_focused 5.926 novice
head_face_mu context_focused 6.283 novice
head_face_mu context_focused 7.002 novice
head_face_mu self_focused 7.031 novice
lower_body_mu self_focused 7.189 novice
upper_body_mu communication_focused 7.45 novice
lower_body_mu self_focused 7.632 expert 1.144
head_face_mu self_focused 7.739 expert 2.159
lower_body_mu self_focused 8.943 novice 9.517
head_face_mu context_focused 9.002 expert 4.608
這是我的圖:
任何反饋和評論都非常歡迎!
先感謝您。
嗯,我已經用它玩了一段時間,我已成功地回答你所有的問題只是改變顏色mean
線。 對我來說,在beanplot()
函數中設置col =
爭論是有點挑剔的。 但是,這就是我所擁有的一切:
par(xpd=F, mai = c(1, 1, 1, 2))
beanplot(onset_s~ group*meaning, data=df,ll = 0.08,
main = "Distribution of movement units", side = "both",
col = list("black", c("grey", "white")),
axes=F, beanlines = "median", ylim = c(-5, 15)) #axes = F let's you define your own axes
#now you can define the x and y axes like this
#note - this also takes care of your renaming issue
#although you could just change the character values using subsetting
#axis 1 is the x axis
axis(1, at = 1:3, labels = c("communication-focused", "context-focused", "self-focused"))
#axis 2 is the y axis, and you can change the values in the "at =" vector
axis(2, at = c(-5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15))
#this creates the outer box around the plot, which is removed with axes = F
box(which = "plot")
#This now lets you add things to the graphic system outside of the plotting area
par(xpd=TRUE)
#you will need to change the x and y coordinates
#also, the "cex =' arguement of the legend function controls
#the size of the text, so by setting this equal to one, you achieve larger text
legend(3.7, 15.8,fill = c("grey", "black"), legend = c("Non-Performers", "Experts"), cex=1)
現在,我在beanplot
的col =
參數中嘗試了多種不同的組合來解決您的beanplot
問題。 但是,我得到的最接近的是將該行變成紅色,然后擺脫了每個bean的拆分設置。 我認為您應該只使用不同的組合並在?beanplot
幫助頁面上閱讀該特定參數的描述。
無論如何,我希望這會有所幫助
更新我已經將mai = c()
參數添加到par()
的第一個函數調用中。 此參數使您可以通過以英寸為單位指定每個相應邊距的邊距大小(從下,左,上,右順序)來控制圖形周圍的邊距。 這應該可以解決您的問題。 我添加了圖形圖像以顯示當前的外觀:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.