diff --git a/doc/api/api_changes.rst b/doc/api/api_changes.rst index 357518b8cf36..2f11afb16074 100644 --- a/doc/api/api_changes.rst +++ b/doc/api/api_changes.rst @@ -40,6 +40,12 @@ CocoaAgg backend removed ~~~~~~~~~~~~~~~~~~~~~~~~ The deprecated and not fully functional CocoaAgg backend has been removed. +`round` removed from TkAgg Backend +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The TkAgg backend had its own implementation of the `round` function. This +was unused internally and has been removed. Instead, use either the +`round` builtin function or `numpy.round`. + 'hold' functionality deprecated ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'hold' keyword argument and all functions and methods related diff --git a/examples/pylab_examples/date_index_formatter.py b/examples/pylab_examples/date_index_formatter.py index 1234bb5b5850..a7a4cae52b2c 100644 --- a/examples/pylab_examples/date_index_formatter.py +++ b/examples/pylab_examples/date_index_formatter.py @@ -9,7 +9,7 @@ """ from __future__ import print_function -import numpy +import numpy as np from matplotlib.mlab import csv2rec import matplotlib.pyplot as plt import matplotlib.cbook as cbook @@ -27,7 +27,7 @@ def __init__(self, dates, fmt='%Y-%m-%d'): def __call__(self, x, pos=0): 'Return the label for time x at position pos' - ind = int(round(x)) + ind = int(np.round(x)) if ind >= len(self.dates) or ind < 0: return '' @@ -37,6 +37,6 @@ def __call__(self, x, pos=0): fig, ax = plt.subplots() ax.xaxis.set_major_formatter(formatter) -ax.plot(numpy.arange(len(r)), r.close, 'o-') +ax.plot(np.arange(len(r)), r.close, 'o-') fig.autofmt_xdate() plt.show() diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index ff7ccb461a1b..e3cd4ebf4592 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -210,7 +210,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): #print x, y, int(x), int(y), s self._renderer.draw_text_image( - font, round(x - xd + xo), round(y + yd + yo) + 1, angle, gc) + font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc) def get_text_width_height_descent(self, s, prop, ismath): """ @@ -257,8 +257,8 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None): w, h, d = self.get_text_width_height_descent(s, prop, ismath) xd = d * sin(radians(angle)) yd = d * cos(radians(angle)) - x = round(x + xd) - y = round(y + yd) + x = np.round(x + xd) + y = np.round(y + yd) self._renderer.draw_text_image(Z, x, y, angle, gc) diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 3c4ff72f32aa..b44d7728886d 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -50,9 +50,6 @@ } -def round(x): - return int(math.floor(x+0.5)) - def raise_msg_to_str(msg): """msg is a return arg from a raise. Join with new lines""" if not is_string_like(msg): diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index bfd720d61737..e28d72460be7 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -152,7 +152,7 @@ def flush_images(): gc = renderer.new_gc() gc.set_clip_rectangle(parent.bbox) gc.set_clip_path(parent.get_clip_path()) - renderer.draw_image(gc, round(l), round(b), data) + renderer.draw_image(gc, np.round(l), np.round(b), data) gc.restore() del image_group[:] diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 6bb383e8ee8c..754f2158159d 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -1760,8 +1760,8 @@ def _raw_ticks(self, vmin, vmax): step = max(1, step) best_vmin = (_vmin // step) * step - low = round(Base(step).le(_vmin - best_vmin) / step) - high = round(Base(step).ge(_vmax - best_vmin) / step) + low = np.round(Base(step).le(_vmin - best_vmin) / step) + high = np.round(Base(step).ge(_vmax - best_vmin) / step) ticks = np.arange(low, high + 1) * step + best_vmin + offset nticks = ((ticks <= vmax) & (ticks >= vmin)).sum() if nticks >= self._min_n_ticks: