has2k1 / has2k1/plotnine

How to add white border around text?

Open
#974 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Documentation
Dominant language
Python
Stars
4.8k
Forks
254
Avg merge
10h 35m
Merged PRs (30d)
9

Description

Discussed in https://github.com/has2k1/plotnine/discussions/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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the discussion at github.com/has2k1/plotnine/discussions/898 and review the linked input file to understand the requested text-label effect and the existing plotnine example. Locate the appropriate documentation example area, add a reproducible example, and verify that it demonstrates a white border around text labels without the misalignment shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.