8000 use np.radians/np.degrees in examples/api where appropriate · matplotlib/matplotlib@33b10ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 33b10ba

Browse files
committed
use np.radians/np.degrees in examples/api where appropriate
1 parent 705c4f9 commit 33b10ba

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

examples/api/custom_projection_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ def format_coord(self, lon, lat):
273273
274274
In this case, we want them to be displayed in degrees N/S/E/W.
275275
"""
276-
lon = lon * (180.0 / np.pi)
277-
lat = lat * (180.0 / np.pi)
276+
lon = np.degrees(lon)
277+
lat = np.degrees(lat)
278278
if lat >= 0.0:
279279
ns = 'N'
280280
else:
@@ -297,7 +297,7 @@ def __init__(self, round_to=1.0):
297297
self._round_to = round_to
298298

299299
def __call__(self, x, pos=None):
300-
degrees = (x / np.pi) * 180.0
300+
degrees = np.degrees(x)
301301
degrees = round(degrees / self._round_to) * self._round_to
302302
# \u00b0 : degree symbol
303303
return "%d\u00b0" % degrees
@@ -350,7 +350,7 @@ def set_longitude_grid_ends(self, degrees):
350350
class -- it provides an interface to something that has no
351351
analogy in the base Axes class.
352352
"""
353-
longitude_cap = degrees * (np.pi / 180.0)
353+
longitude_cap = np.radians(degrees)
354354
# Change the xaxis gridlines transform so that it draws from
355355
# -degrees to degrees, rather than -pi to pi.
356356
self._xaxis_pretransform \

examples/api/custom_scale_example.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, axis, **kwargs):
4242
thresh: The degree above which to crop the data.
4343
"""
4444
mscale.ScaleBase.__init__(self)
45-
thresh = kwargs.pop("thresh", (85 / 180.0) * np.pi)
45+
thresh = kwargs.pop("thresh", np.radians(85))
4646
if thresh >= np.pi / 2.0:
4747
raise ValueError("thresh must be less than pi/2")
4848
self.thresh = thresh
@@ -74,11 +74,10 @@ class DegreeFormatter(Formatter):
7474

7575
def __call__(self, x, pos=None):
7676
# \u00b0 : degree symbol
77-
return "%d\u00b0" % ((x / np.pi) * 180.0)
77+
return "%d\u00b0" % np.degrees(x)
7878

79-
deg2rad = np.pi / 180.0
8079
axis.set_major_locator(FixedLocator(
81-
np.arange(-90, 90, 10) * deg2rad))
80+
np.radians(np.arange(-90, 90, 10))))
8281
axis.set_major_formatter(DegreeFormatter())
8382
axis.set_minor_formatter(DegreeFormatter())
8483

examples/api/joinstyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def plot_angle(ax, x, y, angle, style):
11-
phi = angle / 180 * np.pi
11+
phi = np.radians(angle)
1212
xx = [x + .5, x, x + .5 * np.cos(phi)]
1313
yy = [y, y, y + .5 * np.sin(phi)]
1414
ax.plot(xx, yy, lw=8, color='blue', solid_joinstyle=style)

examples/api/radar_chart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _close_line(self, line):
7676
line.set_data(x, y)
7777

7878
def set_varlabels(self, labels):
79-
self.set_thetagrids(theta * 180 / np.pi, labels)
79+
self.set_thetagrids(np.degrees(theta), labels)
8080

8181
def _gen_axes_patch(self):
8282
return self.draw_patch()

examples/api/sankey_demo_old.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def sankey(ax,
4444

4545
def add_output(path, loss, sign=1):
4646
# Arrow tip height
47-
h = (loss / 2 + w) * np.tan(outangle / 180. * np.pi)
47+
h = (loss / 2 + w) * np.tan(np.radians(outangle))
4848
move, (x, y) = path[-1] # Use last point as reference
4949
if sign == 0: # Final loss (horizontal)
5050
path.extend([(Path.LINETO, [x + dx, y]),
@@ -67,7 +67,7 @@ def add_output(path, loss, sign=1):
6767
outtips.append((sign, path[-5][1]))
6868

6969
def add_input(path, gain, sign=1):
70-
h = (gain / 2) * np.tan(inangle / 180. * np.pi) # Dip depth
70+
h = (gain / 2) * np.tan(np.radians(inangle)) # Dip depth
7171
move, (x, y) = path[-1] # Use last point as reference
7272
if sign == 0: # First gain (horizontal)
7373
path.extend([(Path.LINETO, [x - dx, y]),

0 commit comments

Comments
 (0)
0