Skip to content

Commit f3fa3ce

Browse files
committed
Add close passthrough and redraw labels before show.
1 parent 0a2e00a commit f3fa3ce

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ternary/ternary_axes_subplot.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def figure(ax=None, scale=None, permutation=None):
3232

3333
def mpl_redraw_callback(event, tax):
3434
"""
35-
Callback to properly rotate and redraw text labels when the plot is drawn
35+
Callback to properly rotate and redraw text labels when the plot is drawn
3636
or resized.
3737
3838
Parameters:
3939
event: a matplotlib event
4040
either 'resize_event' or 'draw_event'
4141
tax: TernaryAxesSubplot
42-
the TernaryAxesSubplot
42+
the TernaryAxesSubplot
4343
"""
4444
tax._redraw_labels()
4545

@@ -235,7 +235,7 @@ def line(self, p1, p2, **kwargs):
235235
def horizontal_line(self, i, **kwargs):
236236
ax = self.get_axes()
237237
scale = self.get_scale()
238-
lines.horizontal_line(ax, scale, i, **kwargs)
238+
lines.horizontal_line(ax, scale, i, **kwargs)
239239

240240
def left_parallel_line(self, i, **kwargs):
241241
ax = self.get_axes()
@@ -249,17 +249,21 @@ def right_parallel_line(self, i, **kwargs):
249249

250250
# Matplotlib passthroughs
251251

252+
def close(self):
253+
fig = self.get_figure()
254+
pyplot.close(fig)
255+
252256
def legend(self, *args, **kwargs):
253257
ax = self.get_axes()
254258
ax.legend(*args, **kwargs)
255259

256260
def savefig(self, filename, dpi=200, format=None):
257261
self._redraw_labels()
258-
figure = self.get_figure()
259-
figure.savefig(filename, format=format, dpi=dpi)
262+
fig = self.get_figure()
263+
fig.savefig(filename, format=format, dpi=dpi)
260264

261-
@staticmethod
262265
def show(self):
266+
self._redraw_labels()
263267
pyplot.show()
264268

265269
# Axis ticks
@@ -302,7 +306,7 @@ def ticks(self, ticks=None, locations=None, multiple=1, axis='blr',
302306
ax = self.get_axes()
303307
scale = self.get_scale()
304308
lines.ticks(ax, scale, ticks=ticks, locations=locations,
305-
multiple=multiple, clockwise=clockwise, axis=axis,
309+
multiple=multiple, clockwise=clockwise, axis=axis,
306310
axes_colors=axes_colors, tick_formats=tick_formats,
307311
**kwargs)
308312

@@ -337,7 +341,7 @@ def _redraw_labels(self):
337341
**kwargs)
338342
text.set_rotation_mode("anchor")
339343
self._to_remove.append(text)
340-
344+
341345
def convert_coordinates(self, points, axisorder='blr'):
342346
"""
343347
Convert data coordinates to simplex coordinates for plotting

0 commit comments

Comments
 (0)