Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding points to different x that the one used by ggbarplot #173

Closed
elenichri opened this issue Apr 10, 2019 · 2 comments
Closed

Adding points to different x that the one used by ggbarplot #173

elenichri opened this issue Apr 10, 2019 · 2 comments

Comments

@elenichri
Copy link

Hello,
I have a problem with adding points after doing the barplot: The points are added in the middle of the group. I want however to add them at each bar of the group. So the x for the points should be different from the x for the x for the barplot. How can I do that? Here is my code:

ggbarplot(melted_fig4a.dmso, x = 'drug', y = 'value', width=0.8, add = c("mean_sd"), add.params = list(color='black', group='compound_concentration'), font.xtickslab = 20, font.x=22, font.ytickslab = 20, font.y=22, ylim=c(0,15), color='compound_concentration', #no, group by concentration fill='compound_concentration', position=position_dodge(0.8), palette='grey', x.text.angle=90) + geom_point(size=2, data= melted_fig4a.dmso, aes(x=treatment, y=value))

This adds the points in different columns AFTER the bars of each group

Here are the top 15 lines of the melted_fig4a.dmso
treatment compound_concentration replicate value drug
None 1 rep1 0.33 None
Dima 1 1 rep1 0.73 Dima
Dima 10 2 rep1 1.03 Dima
Dima 100 3 rep1 2.49 Dima
Quin 1 1 rep1 0.74 Quin
Quin 10 2 rep1 0.46 Quin
Quin 100 3 rep1 0.53 Quin
Colc 0.0025 1 rep1 1.35 Colc
Colc 0.005 2 rep1 2.41 Colc
Colc 0.01 3 rep1 1.53 Colc
Meb 0.05 1 rep1 0.38 Meb
Meb 0.1 2 rep1 1.11 Meb
Podo 0.005 1 rep1 0.68 Podo
Podo 0.01 2 rep1 1.02 Podo
Dino 1 1 rep1 0.74 Dino

I would very much appreciate your help

Eleni

@elenichri
Copy link
Author

Here is how the above looks
wrong_ggbarplot1

Alternatively, if I do ggbarplot(melted_fig4a.dmso, x = 'drug', y = 'value', width=0.8, add = c("mean_sd"), add.params = list(color='black', group='compound_concentration'), font.xtickslab = 20, font.x=22, font.ytickslab = 20, font.y=22, ylim=c(0,15), color='compound_concentration', #no, group by concentration fill='compound_concentration', position=position_dodge(0.8), palette='grey', x.text.angle=90) + geom_point(size=2)

I get the following (wrong again) plot
wrong_ggbarplot2

Any help is much appreciated. I have been trying to solve this problem fora whole working day!
Thank you very much.

@kassambara
Copy link
Owner

Fixed now, thanks!

You can Install the latest dev version and try:

library(ggpubr)
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggbarplot(ToothGrowth, x = "dose", y = "len", 
          add = c("mean_se", "point"),
          fill = "supp", palette = "grey",
          position = position_dodge(0.8))

Rplot14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants