diff --git a/examples/misc/custom_projection.py b/examples/misc/custom_projection.py index 39fb58a1e768..fedee56a4be8 100644 --- a/examples/misc/custom_projection.py +++ b/examples/misc/custom_projection.py @@ -450,8 +450,7 @@ def _get_core_transform(self, resolution): return self.HammerTransform(resolution) -# Now register the projection with matplotlib so the user can select -# it. +# Now register the projection with Matplotlib so the user can select it. register_projection(HammerAxes) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 2be35ddb5697..fd724f55876c 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -9,9 +9,7 @@ import numpy as np from numpy import ma -import matplotlib -from matplotlib import _preprocess_data - +from matplotlib import _preprocess_data, rcParams import matplotlib.cbook as cbook import matplotlib.collections as mcoll import matplotlib.colors as mcolors @@ -39,8 +37,6 @@ _log = logging.getLogger(__name__) -rcParams = matplotlib.rcParams - def _make_inset_locator(bounds, trans, parent): """ diff --git a/lib/matplotlib/backends/backend_cairo.py b/lib/matplotlib/backends/backend_cairo.py index d202f0494625..b14b94e91b76 100644 --- a/lib/matplotlib/backends/backend_cairo.py +++ b/lib/matplotlib/backends/backend_cairo.py @@ -6,7 +6,6 @@ This backend depends on cairocffi or pycairo. """ -import copy import gzip import numpy as np diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 8e2818f098e1..794fd61b7ca1 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -9,11 +9,10 @@ from functools import total_ordering from io import BytesIO import logging -from math import ceil, cos, floor, pi, sin +import math import os import re import struct -import sys import time import types import warnings @@ -890,9 +889,9 @@ def cvt(length, upe=font.units_per_EM, nearest=True): # Perhaps best to round away from zero for bounding # boxes and the like if value < 0: - return floor(value) + return math.floor(value) else: - return ceil(value) + return math.ceil(value) def embedTTFType3(font, characters, descriptor): """The Type 3-specific part of embedding a Truetype font""" @@ -1818,9 +1817,9 @@ def _setup_textpos(self, x, y, angle, oldx=0, oldy=0, oldangle=0): if angle == oldangle == 0: self.file.output(x - oldx, y - oldy, Op.textpos) else: - angle = angle / 180.0 * pi - self.file.output(cos(angle), sin(angle), - -sin(angle), cos(angle), + angle = math.radians(angle) + self.file.output(math.cos(angle), math.sin(angle), + -math.sin(angle), math.cos(angle), x, y, Op.textmatrix) self.file.output(0, 0, Op.textpos) @@ -1836,10 +1835,11 @@ def draw_mathtext(self, gc, x, y, s, prop, angle): global_fonttype = rcParams['pdf.fonttype'] # Set up a global transformation matrix for the whole math expression - a = angle / 180.0 * pi + a = math.radians(angle) self.file.output(Op.gsave) - self.file.output(cos(a), sin(a), -sin(a), cos(a), x, y, - Op.concat_matrix) + self.file.output(math.cos(a), math.sin(a), + -math.sin(a), math.cos(a), + x, y, Op.concat_matrix) self.check_gc(gc, gc._rgb) self.file.output(Op.begin_text) @@ -2058,9 +2058,10 @@ def draw_text_woven(chunks): # Do the rotation and global translation as a single matrix # concatenation up front self.file.output(Op.gsave) - a = angle / 180.0 * pi - self.file.output(cos(a), sin(a), -sin(a), cos(a), x, y, - Op.concat_matrix) + a = math.radians(angle) + self.file.output(math.cos(a), math.sin(a), + -math.sin(a), math.cos(a), + x, y, Op.concat_matrix) # Output all the 1-byte characters in a BT/ET group, then # output all the 2-byte characters. diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 815653927b6e..b62edf181319 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -2,7 +2,6 @@ import types import numpy as np -import warnings from matplotlib.axes import Axes import matplotlib.axis as maxis diff --git a/lib/matplotlib/tight_layout.py b/lib/matplotlib/tight_layout.py index 06ab3927ec57..68b1e70c0bcb 100644 --- a/lib/matplotlib/tight_layout.py +++ b/lib/matplotlib/tight_layout.py @@ -9,12 +9,9 @@ for some cases (for example, left or right margin is affected by xlabel). """ -import matplotlib -from matplotlib import cbook -from matplotlib.transforms import TransformedBbox, Bbox - +from matplotlib import cbook, rcParams from matplotlib.font_manager import FontProperties -rcParams = matplotlib.rcParams +from matplotlib.transforms import TransformedBbox, Bbox def _get_left(tight_bbox, axes_bbox):