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

Skip to content

Commit 68690fc

Browse files
authored
Merge pull request #11757 from stilley2/master
PGF backend output text color even if black
2 parents e9feb7c + 27cf3a0 commit 68690fc

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

doc/api/api_changes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,12 @@ Colorbar for log-scaled hexbin
470470
When using `hexbin` and plotting with a logarithmic color scale, the colorbar
471471
ticks are now correctly log scaled. Previously the tick values were linear
472472
scaled log(number of counts).
473+
474+
PGF backend now explicitly makes black text black
475+
-------------------------------------------------
476+
477+
Previous behavior with the pgf backend was for text specified as black to
478+
actually be the default color of whatever was rendering the pgf file (which was
479+
of course usually black). The new behavior is that black text is black,
480+
regardless of the default color. However, this means that there is no way to
481+
fall back on the default color of the renderer.

lib/matplotlib/backends/backend_pgf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,10 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
673673
writeln(self.fh, r"\pgfsetfillopacity{%f}" % alpha)
674674
writeln(self.fh, r"\pgfsetstrokeopacity{%f}" % alpha)
675675
rgb = tuple(gc.get_rgb())[:3]
676-
if rgb != (0, 0, 0):
677-
writeln(self.fh, r"\definecolor{textcolor}{rgb}{%f,%f,%f}" % rgb)
678-
writeln(self.fh, r"\pgfsetstrokecolor{textcolor}")
679-
writeln(self.fh, r"\pgfsetfillcolor{textcolor}")
680-
s = r"\color{textcolor}" + s
676+
writeln(self.fh, r"\definecolor{textcolor}{rgb}{%f,%f,%f}" % rgb)
677+
writeln(self.fh, r"\pgfsetstrokecolor{textcolor}")
678+
writeln(self.fh, r"\pgfsetfillcolor{textcolor}")
679+
s = r"\color{textcolor}" + s
681680

682681
f = 1.0 / self.figure.dpi
683682
text_args = []

0 commit comments

Comments
 (0)