Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to add white border around text? #974

@has2k1

Description

@has2k1

Discussed in #898

Originally posted by aborruso December 7, 2024
Hi,
I would like to add a thin white border to text labels

(
    ggplot(geo_df)
    + geom_map(aes(fill="costo_per_km2"), color="black", size=0.1)
    + scale_fill_cmap(cmap_name="YlOrRd")
    + geom_text(
        aes("center_lon", "center_lat", label="DEN_REGIONE"), size=8,color="black"
    )
    + labs(fill="Costo €/km²")
    + theme(
        panel_background=element_rect(fill="white"),
        panel_grid=element_blank(),
        axis_text=element_blank(),
        axis_ticks=element_blank(),
        axis_title=element_blank(),
    )
)

image

If I simply clone the text layers, and change the dimensions, then they turn out centered differently

    + geom_text(
        aes("center_lon", "center_lat", label="DEN_REGIONE"), size=8,color="white"
    )
    + geom_text(
        aes("center_lon", "center_lat", label="DEN_REGIONE"), size=6,color="black"
    )

image

This is my input file.

Thank you

Create an example in the documentation

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions