3
我使用以下代碼生成我想要的圖形ggplot2中的以下數據集。我想拉布勒由組x軸的PTIDs使其顯示它們是如何已經顯示ptids也與他們在哪個組。按組標記X軸值
PTID Group variable value
1 subject1 Group 1 Bio.V3.B 43
2 subject2 Group 1 Bio.V3.B 7410
3 subject3 Group 2 Bio.V3.B 13227
4 subject4 Group 2 Bio.V3.B 4832
5 subject5 Group 3 Bio.V3.B 205
6 subject6 Group 3 Bio.V3.B 24899
1 subject1 Group 1 Bio.V3.C 496
2 subject2 Group 1 Bio.V3.C 5932
3 subject3 Group 2 Bio.V3.C 24093
4 subject4 Group 2 Bio.V3.C 85
5 subject5 Group 3 Bio.V3.C 9503
6 subject6 Group 3 Bio.V3.C 18249
ggplot(data=meltedwk28v3, aes(x=PTID, y=value, fill=variable)) +
geom_bar(width= .5, colour="black", stat="identity", #barwidth
position=position_dodge(width=.7), #gapwidth
size=.2) + # Thinner lines
scale_fill_hue(name="Bio-V3 Clade") + # Set legend title
xlab("PTID") + ylab("MFI") + # Set axis labels
ggtitle("Wk28 Bio-V3 MFI") + # Set title
theme_classic() + theme(axis.text.x = element_text(angle=90, hjust=0, vjust=0)) #Themes
謝謝!
謝謝你這點我在正確的方向! – AwesomeeExpress
對於更復雜的標籤,請參閱[**這裏**](http://stackoverflow.com/questions/18165863/ggplot2-labels-of-grouping-values-below-the-plot?rq=1) – Henrik
@AwesomeeExpress,這可能是一個好主意如果您發現它有用,請接受並讚揚此答案。 –