Matthew Perkins
Matthew Perkins

Reputation: 131

Oreo colored text possible in matplotlib?

Is there an easy way to have text (specifically axis-label text) with a white outline color, but black fill color. My axis labels fall over portions of my graph that are in some areas are light and others dark, so some label are obscured.

An easy way to solve this problem would be to set the background color of the axis-label text object.

I find the square boxes distracting and if possible, would prefer that the text itself has an inverse oreo coloring.

Upvotes: 13

Views: 2401

Answers (1)

Paul McMillan
Paul McMillan

Reputation: 20107

You should be able to pull this off using PathEffects, and ax.(x/y)axis.label or ax.get_(x/y)ticklabels() to get the txt objects.

See the examples here: https://matplotlib.org/stable/gallery/misc/patheffect_demo.html

Upvotes: 8

Related Questions