Skip to content

Commit fcdfc57

Browse files
committed
Merge branch 'develop' into 'master'
merge develop into master See merge request Scientific-IT-Systems/python-gr!305
2 parents c9415b7 + 6cf60b9 commit fcdfc57

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import matplotlib.pyplot as plt
2+
3+
fig, ax = plt.subplots()
4+
5+
ax.plot([1, 2, 3], label=r'$\sqrt{x^2}$')
6+
ax.legend()
7+
8+
ax.set_xlabel(r'$\Delta_i^j$', fontsize=20)
9+
ax.set_ylabel(r'$\Delta_{i+1}^j$', fontsize=20)
10+
ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} '
11+
r'\Delta_{i+1}^j$', fontsize=20)
12+
13+
tex = r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\sin(2 \pi f x_i)$'
14+
ax.text(1, 1.6, tex, fontsize=20, va='bottom')
15+
16+
fig.tight_layout()
17+
plt.show()

gr/matplotlib/backend_gr.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RendererGR(RendererBase):
2626
Handles drawing/rendering operations using GR
2727
"""
2828

29-
def __init__(self, dpi, width, height):
29+
def __init__(self, width, height, dpi):
3030
super(RendererGR, self).__init__()
3131
self.dpi = dpi
3232
if __version__[0] >= '2':
@@ -138,20 +138,22 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
138138
self.draw_mathtext(x, y, angle, Z)
139139

140140
def _draw_mathtext(self, gc, x, y, s, prop, angle):
141-
ox, oy, width, height, descent, image = \
142-
self.mathtext_parser.parse(s, self.dpi, prop)
143-
self.draw_mathtext(x, y, angle, 255 - np.asarray(image))
141+
ox, oy, width, height, descent, image = \
142+
self.mathtext_parser.parse(s, self.dpi, prop)
143+
self.draw_mathtext(x, y, angle, 255 - np.asarray(image))
144144

145145
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
146+
gr.settextfontprec(233, 3)
146147
if ismath:
147-
self._draw_mathtext(gc, x, y, s, prop, angle)
148+
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath)
148149
else:
149150
x, y = gr.wctondc(x, y)
150151
fontsize = prop.get_size_in_points()
151152
rgba = gc.get_rgb()[:4]
152153
color = gr.inqcolorfromrgb(rgba[0], rgba[1], rgba[2])
153154
gr.settransparency(rgba[3])
154155
gr.setcolorrep(color, rgba[0], rgba[1], rgba[2])
156+
gr.settextalign(1, 4)
155157
gr.setcharheight(fontsize * self.nominal_fontsize)
156158
gr.settextcolorind(color)
157159
if angle != 0:
@@ -239,7 +241,10 @@ class FigureCanvasGR(FigureCanvasBase):
239241
def __init__(self, figure):
240242
FigureCanvasBase.__init__(self, figure)
241243
width, height = self.get_width_height()
242-
self.renderer = RendererGR(figure.dpi, width, height)
244+
self.renderer = RendererGR(width, height, figure.dpi)
245+
246+
def get_renderer(self):
247+
return self.renderer
243248

244249
def draw(self):
245250
"""

0 commit comments

Comments
 (0)