我正在尝试在R中绘制堆积条形图。我已经设置了我认为正确组织下面显示的数据的方法。我使用以下数据框(df_long):
>Sample Class value
>1 MR.EBB SubsectionV 0.376271587
>2 MR.EFT SubsectionV 0.214530230
>3 MW.EBB SubsectionV 0.283043915
>4 MW.EFT SubsectionV 0.231542000
>5 MM.EBB SubsectionV 0.173081478
>6 MM.EFT SubsectionV 0.289146505
>7 MR.EBB Aquificae 0.158061273
>8 MR.EFT Aquificae 0.062513166
>9 MW.EBB Aquificae 0.059306831
>10 MW.EFT Aquificae 0.056433067
>11 MM.EBB Aquificae 0.017349597
>12 MM.EFT Aquificae 0.017775538
>13 MR.EBB Thermales 0.101253844
>14 MR.EFT Thermales 0.033099853
>15 MW.EBB Thermales 0.112873134
>16 MW.EFT Thermales 0.104786977
>17 MM.EBB Thermales 0.048495973
>18 MM.EFT Thermales 0.075336022
>19 MR.EBB Planctomycetacia 0.080287438
>20 MR.EFT Planctomycetacia 0.279834632
>21 MW.EBB Planctomycetacia 0.161093571
>22 MW.EFT Planctomycetacia 0.171961995
>23 MM.EBB Planctomycetacia 0.106702984
>24 MM.EFT Planctomycetacia 0.125403226
>25 MR.EBB Caldilineae 0.066832269
>26 MR.EFT Caldilineae 0.028834000
>27 MW.EBB Caldilineae 0.008431401
>28 MW.EFT Caldilineae 0.028050109
>29 MM.EBB Caldilineae 0.192444339
>30 MM.EFT Caldilineae 0.124495968
>31 MR.EBB unclassified 0.055713272
>32 MR.EFT unclassified 0.076732673
>33 MW.EBB unclassified 0.116173938
>34 MW.EFT unclassified 0.118857420
>35 MM.EBB unclassified 0.060575557
>36 MM.EFT unclassified 0.051008065
>37 MR.EBB Deltaproteobacteria 0.022208422
>38 MR.EFT Deltaproteobacteria 0.027122393
>39 MW.EBB Deltaproteobacteria 0.023285017
>40 MW.EFT Deltaproteobacteria 0.020091987
>41 MM.EBB Deltaproteobacteria 0.045239223
>42 MM.EFT Deltaproteobacteria 0.035215054
>43 MR.EBB Nitrospira 0.021764845
>44 MR.EFT Nitrospira 0.040841584
>45 MW.EBB Nitrospira 0.026729334
>46 MW.EFT Nitrospira 0.034162430
>47 MM.EBB Nitrospira 0.015040265
>48 MM.EFT Nitrospira 0.022547043
>49 MR.EBB Clostridia 0.020995978
>50 MR.EFT Clostridia 0.032362545
>51 MW.EBB Clostridia 0.025114811
>52 MW.EFT Clostridia 0.020666909
>53 MM.EBB Clostridia 0.026527712
>54 MM.EFT Clostridia 0.035282258
>55 MR.EBB Thermodesulfobacteria 0.020877691
>56 MR.EFT Thermodesulfobacteria 0.044607120
>57 MW.EBB Thermodesulfobacteria 0.054104478
>58 MW.EFT Thermodesulfobacteria 0.051228516
>59 MM.EBB Thermodesulfobacteria 0.011724301
>60 MM.EFT Thermodesulfobacteria 0.017137097
>61 MR.EBB Chloroflexi 0.014401467
>62 MR.EFT Chloroflexi 0.023857173
>63 MW.EBB Chloroflexi 0.016647532
>64 MW.EFT Chloroflexi 0.030137981
>65 MM.EBB Chloroflexi 0.015810043
>66 MM.EFT Chloroflexi 0.028091398
>67 MR.EBB Sphingobacteria 0.013307310
>68 MR.EFT Sphingobacteria 0.033468506
>69 MW.EBB Sphingobacteria 0.032146958
>70 MW.EFT Sphingobacteria 0.035463568
>71 MM.EBB Sphingobacteria 0.017171956
>72 MM.EFT Sphingobacteria 0.019354839
>73 MR.EBB Actinobacteria 0.011592146
>74 MR.EFT Actinobacteria 0.030071624
>75 MW.EBB Actinobacteria 0.022172790
>76 MW.EFT Actinobacteria 0.024358509
>77 MM.EBB Actinobacteria 0.021435339
>78 MM.EFT Actinobacteria 0.016431452
>79 MR.EBB Acidobacteria 0.009226402
>80 MR.EFT Acidobacteria 0.013455867
>81 MW.EBB Acidobacteria 0.027985075
>82 MW.EFT Acidobacteria 0.032074558
>83 MM.EBB Acidobacteria 0.036949313
>84 MM.EFT Acidobacteria 0.039784946
>85 MR.EBB OTHER 0.027206056
>86 MR.EFT OTHER 0.058668633
>87 MW.EBB OTHER 0.030891217
>88 MW.EFT OTHER 0.040183975
>89 MM.EBB OTHER 0.211451919
>90 MM.EFT OTHER 0.102990591
这是我的图表输入:
>ggplot(df_long, aes(x=Sample, y= value, fill= Class))
> geom_bar(stat = "identity")
当我尝试绘制图形时,没有任何条形显示。绘图区域在那里,轴标签是正确的,但根本没有条形。任何帮助表示赞赏
答案 0 :(得分:0)
我们需要使用+
ggplot(df_long, aes(x=Sample, y= value, fill= Class)) +
geom_bar(stat = "identity")