Questions tagged [ggpattern]

Use this tag for questions related to the ggpattern package. The ggpattern package is an extension package for {ggplot2} which "provides geoms filled with various patterns".

The package provides

geoms filled with various patterns. Includes a patterned version of every geom that has a region that can be filled with a pattern. Provides a suite of aesthetics and scales for controlling pattern appearances. Supports over a dozen builtin patterns (every pattern implemented by {gridpattern}) as well as allowing custom user-defined patterns.

An overview and introduction to the package can be found on the package website

31 questions
3
votes
2 answers

ggpattern - Pattern for a specified value of variable

I tried to represent species presence into containers breeding site. I used a bar plot and a color code to represent my different species. I first tried to specify a color for each value of my sp variable, but it appeared to be to much colored as I…
HMK
  • 47
  • 4
3
votes
3 answers

Error in seq.default(from, to, by) : invalid '(to - from)/by ggpattern

I'm using geom_bar_pattern to try to put stripes in an stacked barplot. I could run the command once, but I'm trying to do it again and it doesn't work. The error is Error in seq.default(from, to, by) : invalid '(to - from)/by'
2
votes
1 answer

ggpattern change pattern spacing without changing size

I want to create a figure using ggpattern to fill certain polygons with a dotted pattern, in a such a way that each polygon has a different density of dots. That is, I want the number of dots per area to be different between polygons, but still want…
1
vote
1 answer

Scatterpie plot with patterns

I'm using the R scatterpie package for plotting pie charts on an xy plane. Each one of the pies/groups also has a class assignment which I would also like to convey in the plot and was thinking of using patterns for that. Here's the example…
user1701545
  • 5,706
  • 14
  • 49
  • 80
1
vote
0 answers

geom_ribbon_pattern want to add an explanation for the textual area

I want to illustrate the textual area like the variable one. library(ggplot2) library(ggpattern) # Reshape the data into a long format data_long <- data %>% gather(key = "variable", value = "value", NI, GP, SA, CF) ggplot() + #geom_line(data…
s Murasame
  • 11
  • 3
1
vote
2 answers

How to dodge and stack a bar plot with a pattern in R?

I have a dataframe in R which is as below : library(dplyr) library(ggplot2) library(ggraph) library(scales) library(ggpattern) df <- structure(list(Category_A = c("Class_A", "Class_A", "Class_A", "Class_A", "Class_A", "Class_A", "Class_C",…
AneesBaqir
  • 423
  • 1
  • 12
1
vote
1 answer

ggplot2: How to stack patterned columns in a facet grid plot?

Suppose that I have data on gender distribution (female, male, divers) in three different countries (USA, Nepal, Japan) with three different locations each (province, small town, city) for two years (2019, 2022). I want to display all of these data…
Deeja
  • 13
  • 3
1
vote
1 answer

How to restrict the ggplot legend rows (with guide_legend) when using ggpattern?

I am trying to restrict the legend of a ggplot (with ggpattern) to 2 rows. It is more or less straightforward here when you only have one aesthetic to play with. Additionally, this is a good example of how to manipulate legends with more than 1…
Dylan_Gomes
  • 2,066
  • 14
  • 29
1
vote
1 answer

How to remove border colour of geom_rect_pattern from {ggpattern}?

I want to plot two rectangles with internal gradients beside each other using ggpattern::geom_rect_pattern(pattern = "gradient") without a border around each rectangle. Example: library(tidyverse) library(ggpattern) tibble( id = c("a", "b"), …
1
vote
1 answer

How to keep the (stripe) pattern in the legend when saving a plot (R-ggplot-ggpattern)

I am not able to save the chart as an image (png or other) keeping the **stripe **pattern in the legend. Dot patterns and others work, but not stripes. Could anyone give me some advice? Thanks in advance for your help My sample…
masamo21
  • 11
  • 1
1
vote
1 answer

Cannot group boxplots or add manual legend using ggpattern and 2 datasets

I am quite new to R in general and currently struggling with a specific plot I want to create. Preferably I would like to group my boxplots (2 per Area -> Good Habitat, average habitat etc.) and add a legend. Since I am using two datasets from two…
1
vote
2 answers

Pattern from ggpattern disappears in legend only in pdf or png output

When I use the ggpattern package, it produces a great plot with a working legend in the Rstudio IDE. However, when I export to pdf or png, the legend fails to include two pattern types. Data for reproducible question at bottom of post. #…
Dylan_Gomes
  • 2,066
  • 14
  • 29
1
vote
1 answer

How to edit a ggpattern legend in a bar plot with more than one legend?

How can I edit the legend for the patterns while leaving the other legend as is when using ggpatterns? I have the following plot: I used the following code to make this plot: ggplot(try2, aes(Season, prey_frq, fill=PreyName, pattern = Type)) + …
FishyFishies
  • 301
  • 3
  • 14
1
vote
0 answers

R: Running code with reprex() produces expected output but running it from RStudio console produces error

When I select and copy all of the below code and then call reprex::reprex(), it successfully produces two plots. However, when I run the code by selecting all of the code and then pressing Cntrl + Enter from RStudio, it only produces the first plot…
socialscientist
  • 3,759
  • 5
  • 23
  • 58
0
votes
1 answer

Using ggpattern with white pattern; fill and pattern different variables: How do I add a grey background to the pattern legend?

I am working on a graph and am using color and pattern for two different variables. I want the graph to have colored designs created by using a white pattern over the colored fills. (I tried making the pattern colored, but when the pattern color and…
1
2 3