Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use np.radians/np.degrees in examples/api where appropriate
  • Loading branch information
twmr committed Jul 2, 2014
commit 33b10ba67338145d84968762e9056307d2c81f93
8 changes: 4 additions & 4 deletions examples/api/custom_projection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ def format_coord(self, lon, lat):

In this case, we want them to be displayed in degrees N/S/E/W.
"""
lon = lon * (180.0 / np.pi)
lat = lat * (180.0 / np.pi)
lon = np.degrees(lon)
lat = np.degrees(lat)
if lat >= 0.0:
ns = 'N'
else:
Expand All @@ -297,7 +297,7 @@ def __init__(self, round_to=1.0):
self._round_to = round_to

def __call__(self, x, pos=None):
degrees = (x / np.pi) * 180.0
degrees = np.degrees(x)
degrees = round(degrees / self._round_to) * self._round_to
# \u00b0 : degree symbol
return "%d\u00b0" % degrees
Expand Down Expand Up @@ -350,7 +350,7 @@ def set_longitude_grid_ends(self, degrees):
class -- it provides an interface to something that has no
analogy in the base Axes class.
"""
longitude_cap = degrees * (np.pi / 180.0)
longitude_cap = np.radians(degrees)
# Change the xaxis gridlines transform so that it draws from
# -degrees to degrees, rather than -pi to pi.
self._xaxis_pretransform \
Expand Down
7 changes: 3 additions & 4 deletions examples/api/custom_scale_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, axis, **kwargs):
thresh: The degree above which to crop the data.
"""
mscale.ScaleBase.__init__(self)
thresh = kwargs.pop("thresh", (85 / 180.0) * np.pi)
thresh = kwargs.pop("thresh", np.radians(85))
if thresh >= np.pi / 2.0:
raise ValueError("thresh must be less than pi/2")
self.thresh = thresh
Expand Down Expand Up @@ -74,11 +74,10 @@ class DegreeFormatter(Formatter):

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

deg2rad = np.pi / 180.0
axis.set_major_locator(FixedLocator(
np.arange(-90, 90, 10) * deg2rad))
np.radians(np.arange(-90, 90, 10))))
axis.set_major_formatter(DegreeFormatter())
axis.set_minor_formatter(DegreeFormatter())

Expand Down
2 changes: 1 addition & 1 deletion examples/api/joinstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def plot_angle(ax, x, y, angle, style):
phi = angle / 180 * np.pi
phi = np.radians(angle)
xx = [x + .5, x, x + .5 * np.cos(phi)]
yy = [y, y, y + .5 * np.sin(phi)]
ax.plot(xx, yy, lw=8, color='blue', solid_joinstyle=style)
Expand Down
2 changes: 1 addition & 1 deletion examples/api/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _close_line(self, line):
line.set_data(x, y)

def set_varlabels(self, labels):
self.set_thetagrids(theta * 180 / np.pi, labels)
self.set_thetagrids(np.degrees(theta), labels)

def _gen_axes_patch(self):
return self.draw_patch()
Expand Down
4 changes: 2 additions & 2 deletions examples/api/sankey_demo_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def sankey(ax,

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

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