Doesn't the outcome of this suggestion still depend on which fonts and output 
device you are using? ... and that is to some degree still system dependent...

On October 6, 2023 7:50:00 AM PDT, Rui Barradas <ruipbarra...@sapo.pt> wrote:
>Às 10:09 de 06/10/2023, Chris Evans via R-help escreveu:
>> The reason I am asking is that I would like to mark areas on a plot using 
>> geom_polygon() and aes(fill = variable) to fill various polygons forming the 
>> background of a plot with different colours. Then I would like to overlay 
>> that with points representing direction of change: improved, no reliable 
>> change, deteriorated. The obvious symbols to use for those three directions 
>> are an upward arrow, a circle or square and a downward pointing arrow.  
>> There is a solid upward point triangle symbol in R (ph = 17) and there are 
>> both upward and downward pointing open triangle symbols (pch 21 and 25) but 
>> to fill those with a solid colour so they will be visible over the 
>> background requires that I use a fill aesthetic and that gets me a mess with 
>> the legend as I will have used a different fill mapping to fill the 
>> polygons.  This silly reprex shows the issue I think.
>> 
>> library(tidyverse)
>> tibble(x = 2:9, y = 2:9, c = c(rep("A", 5), rep("B", 3))) -> tmpTibPoints
>> tibble(x = c(1, 5, 5, 1), y = c(1, 1, 5, 5), a = rep("a", 4)) -> tmpTibArea1
>> tibble(x = c(5, 10, 10, 5), y = c(1, 1, 5, 5), a = rep("b", 4)) -> 
>> tmpTibArea2
>> tibble(x = c(1, 5, 5, 1), y = c(5, 5, 10, 10), a = rep("c", 4)) -> 
>> tmpTibArea3
>> tibble(x = c(5, 10, 10, 5), y = c(5, 5, 10, 10), a = rep("d", 4)) -> 
>> tmpTibArea4
>> bind_rows(tmpTibArea1,
>>            tmpTibArea2,
>>            tmpTibArea3,
>>            tmpTibArea4) -> tmpTibAreas
>> ggplot(data = tmpTib,
>>         aes(x = x, y = y)) +
>>    geom_polygon(data = tmpTibAreas,
>>                 aes(x = x, y = y, fill = a)) +
>>    geom_point(data = tmpTibPoints,
>>               aes(x = x, y = y, fill = c),
>>               pch = 24,
>>               size = 6)
>> 
>> Does anyone know a way to create a solid downward pointing symbol?  Or 
>> another workaround?
>> 
>> TIA,
>> 
>> Chris
>> 
>Hello,
>
>Maybe you can solve the problem with unicode characters.
>See the two scale_*_manual at the end of the plot.
>
>
>
># Unicode characters for black up- and down-pointing characters
>pts_shapes <- c("\U25B2", "\U25BC") |> setNames(c("A", "B"))
>pts_colors <- c("blue", "red") |> setNames(c("A", "B"))
>
>ggplot(data = tmpTibAreas,
>       aes(x = x, y = y)) +
>  geom_polygon(data = tmpTibAreas,
>               aes(x = x, y = y, fill = a)) +
>  geom_point(data = tmpTibPoints,
>             aes(x = x, y = y, color = c, shape = c),
>             size = 6) +
>  scale_shape_manual(values = pts_shapes) +
>  scale_color_manual(values = pts_colors)
>
>
>
>

-- 
Sent from my phone. Please excuse my brevity.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to