Problem with ggplot

38 views
Skip to first unread message

Shams Khan

unread,
Sep 13, 2022, 1:31:43 PM9/13/22
to ggplot2
Rplot21.jpeg

In the above plot x axis conc is not arranged properly, 5.0 is plotted with 50! and not in between 0 and 10

here is my data set

Treatment    Zn Conc (ppm)    Shoot Length (mm)    SD
C1    0    9.8    1.26
C2    0    15    1
ZN    5    17.16    0.76
ZN    10    13.83    1.89
ZN    15    11.33    1.52
ZN    20    15.66    1.52
ZN    25    12.33    1.52
ZN    50    9.67    1.52
ZB    5    10.5    1.8
ZB    10    7.33    1.15
ZB    15    11    1
ZB    20    10.33    2.08
ZB    25    9.6    1.64
ZB    50    13    2.65

Erich Neuwirth

unread,
Sep 13, 2022, 1:35:44 PM9/13/22
to Shams Khan, ggplot2
You need to send th code producing the chart.

Von meinem iPad gesendet

Am 13.09.2022 um 19:31 schrieb Shams Khan <shams...@gmail.com>:

Rplot21.jpeg
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ggplot2/664087f4-008e-472c-ab61-0cf2b70fd9a2n%40googlegroups.com.
Rplot21.jpeg

Erich Neuwirth

unread,
Sep 13, 2022, 4:36:06 PM9/13/22
to Shams Tabrez Khan, ggp...@googlegroups.com
df$Dose_ppm |> as.numeric() -> df$Dose_ppm 
or
df$Dose_ppm |> as.integer() -> df$Dose_ppm 

But why do you code this variable as character at all?



On Sep 13, 2022, at 8:39 PM, Shams Tabrez Khan <shams...@gmail.com> wrote:

Sir,
Then how to change it to numerical?

On Wed, Sep 14, 2022 at 12:06 AM Erich Neuwirth <erich.n...@univie.ac.at> wrote:
This solves the puzzle. Dose_ppm is a character vector, and the values are sorted lexicographically.

Von meinem iPad gesendet

Am 13.09.2022 um 20:28 schrieb Shams Tabrez Khan <shams...@gmail.com>:


Here is df

df<-data.frame(Mean=c(9.8,15.0,17.2,13.8,11.3,15.7,12.3,9.7,10.5,7.3,11.0,10.3,9.6,13.0),
sd=c(1.3,1.0,0.8,1.9,1.5,1.5,1.5,1.5,1.8,1.2,1.0,2.1,1.6,2.7),
Treatment=as.factor(c("C1","C2","ZN","ZN","ZN","ZN","ZN","ZN","ZB","ZB","ZB","ZB","ZB","ZB")),
Dose_ppm=c("0.0","0.0","5.0","10.0","15.0","20.0","25.0","50.0","5.0","10.0","15.0","20.0","25.0","50.0"),
Insert= c(0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5))

On Tue, Sep 13, 2022 at 11:54 PM Erich Neuwirth <erich.n...@univie.ac.at> wrote:
Please also send the results of str(df)

Von meinem iPad gesendet

Am 13.09.2022 um 19:58 schrieb Shams Tabrez Khan <shams...@gmail.com>:


Thanks Prof. Erich
I used the following code
ggplot(df, aes(x=Dose_ppm, y=Mean, fill=Treatment)) +
geom_bar(position=position_dodge(), alpha = 0.5, stat="identity",
colour='black') + labs(x="Zn Conc (ppm)", y="Germination (%)")

On Tue, Sep 13, 2022 at 11:05 PM Erich Neuwirth <erich.n...@univie.ac.at> wrote:
You need to send th code producing the chart.

Von meinem iPad gesendet

Am 13.09.2022 um 19:31 schrieb Shams Khan <shams...@gmail.com>:

<Rplot21.jpeg>
<Rplot21.jpeg>

Reply all
Reply to author
Forward
0 new messages