ggpattern Package in R (5 Examples) | Draw ggplot2 Plots with Textures | Barplot, Density & Boxplot

preview_player
Показать описание
R code of this video:

group = letters[1:3])
head(data) # Head of example data

remotes::install_github("coolbutuseless/ggpattern")
library("ggpattern") # Load ggpattern package

library("ggplot2") # Load ggplot2 package

ggplot(data, aes(group, x, fill = group)) + # Create barplot with pattern
geom_bar_pattern(stat = "identity")

ggplot(data, aes(group, x, fill = group)) + # Modify colors of pattern
geom_bar_pattern(stat = "identity",
pattern_color = "white",
pattern_fill = "black")

ggplot(data, aes(group, x, fill = group)) + # Different pattern for each group
geom_bar_pattern(stat = "identity",
pattern_color = "white",
pattern_fill = "black",
aes(pattern = group))

ggplot(data, aes(x, fill = group)) + # Create density plot with pattern
geom_density_pattern(pattern_color = "white",
pattern_fill = "black",
aes(pattern = group))

ggplot(data, aes(x, fill = group)) + # Create boxplot with pattern
geom_boxplot_pattern(pattern_color = "white",
pattern_fill = "black",
aes(pattern = group))

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Thanks for very crystal clear video instruction, this is what I was looking in R for a long time!

ramkhadka
Автор

The very state of the art!! Thanks a lot, Joachim!!😃
I had not the chance to check the videos you released lately because this November was very weird for me😐.

agsoutas
Автор

Thanks a lot, Joachim, beautiful explain

azzeddinereghais
Автор

How do change the line pattern type (especially to make the lines thin) and density in the bar graph sir.

jababnamgay
Автор

Hey Joachim, thanks for the tutorial! I'm trying to set a specific texture for each of my 12 bars based on a column in my dataset, but can't figure out how to, do you have any idea?

AnnemiekeDrost
Автор

Very helpful tutorial. However, it does not work on my r studio 4.10 although I downloaded all the packages required. Every time I try to run the code, it hangs and have to close down the r. What could be the problem sir.

jababnamgay
Автор

is there a way to add a pattern only to a specific group?

OrlandoG
Автор

Hello Joachim! your videos are really helpful in data visualizations of my thesis. By any chance, how do you make different patterns of a stacked barplot having only one color, like black?

melvincubyx
Автор

Hello, I am trying to use ggpattern package to generate some bar plot. However, after I load the package, some functions of ggplot2 were not running correctly, I got error message as:Error: 'flip_data' is not an exported object from 'namespace:ggplot2'. How should I fix this? Thanks!

fanliqiong
Автор

But the pattern is not visible in the legend.

AseemPalSingh
visit shbcf.ru