Question: (Closed) How do i reorder the bars in a grouped barplot
0
gravatar for Efolorunso
9 months ago by
Efolorunso0
Efolorunso0 wrote:

I want tthe bars to be in the order:10% runoff, 20% runoff, NOEC, LC50. Thank you in anticipation. Below is my code:

ggplot(pest_ana, aes(x = Pesticides, y = `Concentration (ug/L)`, fill= Concentrations)) + 
  geom_bar(stat = 'identity', position='dodge') + scale_x_discrete(guide = guide_axis(n.dodge=2)) + scale_y_continuous(trans = log10_trans(),
    breaks = trans_breaks("log10", function(x) 10^x),
    labels = trans_format("log10", math_format(10^.x)))

Pesticides  Concentrations  Concentration (ug/L)    Individual
Cypermethrin       NOEC                               4.8                      1
Deltamethrin       NOEC                               3.37                     2
Actara             NOEC                               20000            3
Carbofuran     NOEC                               40.6                     4
Methomyl       NOEC                               260                      5
Endosulfan     NOEC                               10.2                     6
Fenvalerate    NOEC                               6.02                     7
Glyphosate     NOEC                               5000                     8
Mancozeb       NOEC                               301                      9
Cypermethrin       LC50                               0.03                     1
Deltamethrin       LC50                               0.032                    2
Actara             LC50                               322000               3
Carbofuran     LC50                               500                      4
Methomyl       LC50                               4015                     5
Endosulfan     LC50                               0.05                     6
Fenvalerate    LC50                               15                       7
Glyphosate     LC50                               36800            8
Mancozeb       LC50                               11680            9
Cypermethrin       20% runoff                         3.95                     1
Deltamethrin       20% runoff                         0.69                     2
Actara             20% runoff                         3.95                     3
Carbofuran     20% runoff                         78.99                    4
Methomyl       20% runoff                         10.86                    5
Endosulfan     20% runoff                         41.47                    6
Fenvalerate    20% runoff                         8.85                     7
Glyphosate     20% runoff                         14.22                    8
Mancozeb       20% runoff                         74.05                    9
Cypermethrin       10% runoff                         1.97                     1
Deltamethrin       10% runoff                         0.35                     2
Actara             10% runoff                         1.97                     3
Carbofuran     10% runoff                         39.49                    4
Methomyl       10% runoff                         5.43                     5
Endosulfan     10% runoff                         20.73                    6
Fenvalerate    10% runoff                         4.42                     7
Glyphosate     10% runoff                         7.11                     8
Mancozeb       10% runoff                         37.03                    9
ADD COMMENTlink modified 9 months ago by H.Hasani980 • written 9 months ago by Efolorunso0

Hello Efolorunso!

We believe that this post does not fit the main topic of this site.


Please browse the web on how to change order of bars in ggplot.

There are many threads on that in StackExchange.

You will have to set the levels of the column to the desired order.

https://stackoverflow.com/questions/5208679/order-bars-in-ggplot2-bar-graph


For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink modified 9 months ago • written 9 months ago by ATpoint46k
1
gravatar for H.Hasani
9 months ago by
H.Hasani980
Freiburg, Germany
H.Hasani980 wrote:

you need to make Concentration (ug/L) as a factor, with levels ordered according to your need

pest_ana[["Concentration (ug/L)"]] = factor (pest_ana[["Concentration (ug/L)"]] , levels =c("0% runoff", "20% runoff", "NOEC", "LC50"))

hth

ADD COMMENTlink written 9 months ago by H.Hasani980
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2447 users visited in the last hour
_