Skip to content

Saving png with text and border=True leads to artifacts #548

@chudlerk

Description

@chudlerk

Take the following simple code

import ultraplot as uplt

fig,ax = uplt.subplots()
ax.text(
    .5,.5,
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    ha='center',
    color='w',  
    border=True,
    bordercolor='k',
    borderwidth=3,
    )
fig.savefig('C:/Users/kchudler/Downloads/fig_w_border_arg.png')

The figure displays fine on my display. However, if I open the saved png, I see that some of the letters have these weird pointy artifacts in the letter borders:

Image

If I use path_effects instead, the artifacts do not appear:

import matplotlib.patheffects as pe
import ultraplot as uplt

fig,ax = uplt.subplots()
ax.text(
    .5,.5,
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    ha='center',
    color='w',  
    path_effects=[pe.withStroke(linewidth=3, foreground='k')],
    )
fig.savefig('C:/Users/kchudler/Downloads/fig_w_patheffects.png')
Image

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions