Create hatch color in geom_polygon

I want to create a hatch color (with vertical patterns) for one of the variables (claimed) in the map below. How is this possible in ggplot2?

Here is my code so far:

ggplot(data = df3,aes(x=long, y=lat))+
    geom_polygon(aes(group=group,fill=policy),color="gray78",size=0.3,alpha=0.9)+
    scale_fill_manual(values = c("gold","gold3","gray","forestgreen"),
                      breaks=c("Y","Claimed","N","No data"),
                      labels=c("Yes (validated)","Claimed (not validated)", "No", "No data")
        )+
    labs(fill = 'WSP Policy/Regulation Formally Approved'
       ,title = 'WSP Policies by Country'
       ,x = NULL
       ,y = NULL)+
     theme(
        plot.title = element_text(size = 16)
        ,axis.ticks = element_blank()
        ,axis.text = element_blank()
        ,panel.grid = element_blank()
        ,legend.position = c(.14,.35)
        ,legend.background = element_blank()
        ,legend.key = element_blank(),
        legend.title = element_text(size = 8),
        legend.text = element_text(size = 8)
        )
    

You might want to check out one of the ggplot2 extension packages that lets you use a pattern (or hatching) as a fill, e.g. ggpattern or ggrough:
https://coolbutuseless.github.io/2020/04/01/introducing-ggpattern-pattern-fills-for-ggplot/

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.