Closed tacitli closed 3 years ago
Have you tried manually specifying your seven desired "pch" shape
in geom_bar_pattern()
i.e. geom_bar_pattern(shape = c(14, 5, 3, 6, 4, 8, 20))
?
Have you tried manually specifying your seven desired "pch"
shape
ingeom_bar_pattern()
i.e.geom_bar_pattern(shape = c(14, 5, 3, 6, 4, 8, 20))
?
Thank you Trevorld! However, I can't locate where to adjust shape
manually in my script?
Sorry for forgeting to link my entire code
p <- ggplot(df, aes(trt, outcome)) +
geom_col_pattern(
aes(
pattern_shape = trt,
pattern_angle = trt,
pattern_colour = trt
),
pattern = 'points',
pattern_spacing = 0.02,
colour = 'black',
pattern_density = 0.15,
fill = 'white',
pattern_option_1 = 0.1
) +
theme_bw() +
labs(
title = "ggpattern::geom_col_pattern()",
subtitle = "pattern = 'points'"
) +
theme(legend.position = 'none') +
scale_pattern_angle_discrete(range = c(0, 30)) +
coord_fixed(ratio = 1/2)
p
You should move pattern_shape = trt
out of the aes()
and convert it to pattern_shape = c(14, 5, 3, 6, 4, 8, 20)
(this should have as many elements as rows in your data frame, you can choose other points()
shape values as desired).
You should move
pattern_shape = trt
out of theaes()
and convert it topattern_shape = c(14, 5, 3, 6, 4, 8, 20)
(this should have as many elements as rows in your data frame, you can choose otherpoints()
shape values as desired).
Wow😯, I just understand how it works and successfully plot the right figure. Much thanks!
Hi! I came across an error when changing the dataframe to 7 variables:
we will see a warning as:
And in the plot, the 7th variable will not show up.![image](https://user-images.githubusercontent.com/86301631/122934328-04957b00-d3a2-11eb-8abe-eef024de9d5f.png)
Adding
scale_shape_manual(values=1:7)
is not helpful.How can I fix that?