Customize Bar plot in R -GGplot2- in 5 steps : Beautiful publication ready bar plot

preview_player
Показать описание
#barplot #errorbars #ggplot2 #Rprogramming
#R #datavisualisation #Rprogramming #ggplot #datanalysis #barplotcustomisation

This video discuss customisation of barplot in ggplot2 R. Reordering of categories, adding error bars, plot titles, themes and color palletes have been discussed.

library(tidyverse) # for summarizing the data to get means and sds of categories
library(ggsci) # for color palettes of scieintifc journals
library(ggpubr) # for theme pubr

iris_plot = gather(iris,FlPrt,Length,1:4)

iris_plot= group_by(iris_plot, Species,FlPrt)

iris_plot=summarise(iris_plot,mnL=mean(Length),sdL=sd(Length))

iris_plot= ggplot(iris_plot,aes(reorder(Species,mnL),mnL,fill=reorder(FlPrt,mnL)))+
geom_bar(stat="identity",position="dodge")+
geom_text(mapping=aes(label=mnL),position=position_dodge(width=0.9),
cex=2.5,vjust=-4)+
labs(title="Iris: Measurment of floral organs",
subtitle="Length abd width of srpal abd petal",
x="Species",y="Length ib cm",
caption="Data: iris dataset by Edgar Anderson",fill="Description")+
geom_errorbar(mapping=aes(ymin=mnL-sdL,ymax=mnL+sdL),
width=0.2,position=position_dodge(width=0.9))+
theme_classic()+scale_fill_jco()

0:00 Introduction
0:49 Install and load required packages
1:34 Prepare data
2:34 initiate ggplot
3:36 Reorder categories of bars
4:56 Add value labels to bars
6:02 titles of plot elements
7:05 Add error bars
8:39 add theme to plot
10:16 Add color palettes
11:20 concluding remarks
Рекомендации по теме
Комментарии
Автор

Really easy to digest. Thank you so much

rapperiiz
Автор

Thank you, sir, for steering me in the right direction with many of these topics. Your videos are clear and have been very helpful. Thank you so much.

xdclfew
Автор

struggled for a long time trying to make my bar plots, this helped me a lot ! subscribed !

sarahasadraza
Автор

Thanks a lot, very informative tutorial. This Really helps!

niceday
Автор

Thanks to you sir. I will have a beautiful bar plots! Regards from México

garethomarrostroalonso
Автор

explained really well !! Thank you sir

shivamshinde
Автор

Respected Sir, I want to let you know that how much I am thankful for your videos and really appreciate your efforts for teaching us. Thank you so much sir. May god bless you with good health and success !

prititigga
Автор

Dear Sir, your tutorial helped me lot within 11 minutes. I am a very beginner in r studio, just shifted from excel to R for preparing graphs. It will be nice if you make a video or any recommendation regarding my two problems. 1. I want to show the plant height increment within 6 months time period at different treatment groups. It will be a group bar plot. How will I create a group bar plot of my own data like customized data that you showed in the tutorial? 2. which theme provides the barplot that has separated x-axis and y-axis, not joint like the theme_classic() ? Thanks

azharulislam
Автор

If i do not use stat identity here, how can I add count on the bar plot by using geom text? could you please explain it?

nitufahmidakhalique
Автор

I tried this. But my groups are of different lengths, and the bars of different groups are of different widths. Is there a way to fix that?

tenmeh
Автор

Professor, can you demonstrate how to perform a “distance based Redundancy data analysis (db RDA)” in R ?

aravindabellanthudawa
Автор

Sir please help me .... after clicking geom_text coding portion it is showing -
Error in 'fortify()':
'data' must be a <data.frame>, or an object coercible by 'fortify()' not an s3 object with class <gg>/<ggplot>.

JuniorResearchFellow
Автор

suppose you got sales data.

you got items sold, their quantity and value

if I were in excel I would make a bar plot for the value, i.e. sales value, and volume/quantity of items sold as line chart combined with the previous but the latter would use a secondary axis

now, I know such a thing is possible by mapping different data to different geoms but I am facing an issue visualising the quantity on a line chart

any ideas?
x-axis would have categorical labels and the other numeric

ahmedJaber
Автор

Hi, Which color pallete(theme) is suitable for color blind audience?

jtmasombuka
Автор

sir my x-axise is getting arrange alphabetically not according to the csv fill

asmodesustudi
Автор

Hi which color pallete can I use for color blind people?

jtmasombuka