|
7 | 7 | Requirements: |
8 | 8 |
|
9 | 9 | * latex |
10 | | -* \\*Agg backends: dvipng |
11 | | -* PS backend: latex w/ psfrag, dvips, and Ghostscript 8.51 |
12 | | - (older versions do not work properly) |
| 10 | +* \\*Agg backends: dvipng>=1.6 |
| 11 | +* PS backend: psfrag, dvips, and Ghostscript>=8.60 |
13 | 12 |
|
14 | 13 | Backends: |
15 | 14 |
|
|
23 | 22 | texmanager = TexManager() |
24 | 23 | s = ('\\TeX\\ is Number ' |
25 | 24 | '$\\displaystyle\\sum_{n=1}^\\infty\\frac{-e^{i\\pi}}{2^n}$!') |
26 | | - Z = self.texmanager.get_rgba(s, size=12, dpi=80, rgb=(1,0,0)) |
| 25 | + Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1,0,0)) |
27 | 26 |
|
28 | 27 | To enable tex rendering of all text in your matplotlib figure, set |
29 | 28 | text.usetex in your matplotlibrc file or include these two lines in |
|
66 | 65 | cmd_split = ';' |
67 | 66 |
|
68 | 67 |
|
| 68 | +@mpl.cbook.deprecated("2.1") |
69 | 69 | def dvipng_hack_alpha(): |
70 | 70 | try: |
71 | 71 | p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE, |
@@ -123,8 +123,6 @@ class TexManager(object): |
123 | 123 | if texcache is not None: |
124 | 124 | mkdirs(texcache) |
125 | 125 |
|
126 | | - _dvipng_hack_alpha = None |
127 | | - #_dvipng_hack_alpha = dvipng_hack_alpha() |
128 | 126 | # mappable cache of |
129 | 127 | rgba_arrayd = {} |
130 | 128 | grey_arrayd = {} |
@@ -543,46 +541,10 @@ def get_grey(self, tex, fontsize=None, dpi=None): |
543 | 541 | """returns the alpha channel""" |
544 | 542 | key = tex, self.get_font_config(), fontsize, dpi |
545 | 543 | alpha = self.grey_arrayd.get(key) |
546 | | - |
547 | 544 | if alpha is None: |
548 | 545 | pngfile = self.make_png(tex, fontsize, dpi) |
549 | 546 | X = read_png(os.path.join(self.texcache, pngfile)) |
550 | | - |
551 | | - if rcParams['text.dvipnghack'] is not None: |
552 | | - hack = rcParams['text.dvipnghack'] |
553 | | - else: |
554 | | - if TexManager._dvipng_hack_alpha is None: |
555 | | - TexManager._dvipng_hack_alpha = dvipng_hack_alpha() |
556 | | - hack = TexManager._dvipng_hack_alpha |
557 | | - |
558 | | - if hack: |
559 | | - # hack the alpha channel |
560 | | - # dvipng assumed a constant background, whereas we want to |
561 | | - # overlay these rasters with antialiasing over arbitrary |
562 | | - # backgrounds that may have other figure elements under them. |
563 | | - # When you set dvipng -bg Transparent, it actually makes the |
564 | | - # alpha channel 1 and does the background compositing and |
565 | | - # antialiasing itself and puts the blended data in the rgb |
566 | | - # channels. So what we do is extract the alpha information |
567 | | - # from the red channel, which is a blend of the default dvipng |
568 | | - # background (white) and foreground (black). So the amount of |
569 | | - # red (or green or blue for that matter since white and black |
570 | | - # blend to a grayscale) is the alpha intensity. Once we |
571 | | - # extract the correct alpha information, we assign it to the |
572 | | - # alpha channel properly and let the users pick their rgb. In |
573 | | - # this way, we can overlay tex strings on arbitrary |
574 | | - # backgrounds with antialiasing |
575 | | - # |
576 | | - # red = alpha*red_foreground + (1-alpha)*red_background |
577 | | - # |
578 | | - # Since the foreground is black (0) and the background is |
579 | | - # white (1) this reduces to red = 1-alpha or alpha = 1-red |
580 | | - #alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here? |
581 | | - alpha = 1 - X[:, :, 0] |
582 | | - else: |
583 | | - alpha = X[:, :, -1] |
584 | | - |
585 | | - self.grey_arrayd[key] = alpha |
| 547 | + self.grey_arrayd[key] = alpha = X[:, :, -1] |
586 | 548 | return alpha |
587 | 549 |
|
588 | 550 | def get_rgba(self, tex, fontsize=None, dpi=None, rgb=(0, 0, 0)): |
|
0 commit comments