Skip to content

Polar limits enhancements #4699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 21, 2017
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
Next Next commit
STY: PEP8 the rest of PolarAxes code.
  • Loading branch information
QuLogic committed Aug 16, 2017
commit d549014e4dd1c95950207629b65ffa376e211e3c
71 changes: 35 additions & 36 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import math
import warnings

import numpy as np

import matplotlib
rcParams = matplotlib.rcParams
from matplotlib.axes import Axes
import matplotlib.axis as maxis
from matplotlib import cbook
from matplotlib import docstring
import matplotlib.patches as mpatches
import matplotlib.path as mpath
from matplotlib import rcParams
import matplotlib.ticker as mticker
import matplotlib.transforms as mtransforms
import matplotlib.spines as mspines
Expand Down Expand Up @@ -530,8 +524,8 @@ def _set_lim_and_transforms(self):
self._yaxis_text_transform = mtransforms.TransformWrapper(
self._r_label_position + self.transData)

def get_xaxis_transform(self,which='grid'):
if which not in ['tick1','tick2','grid']:
def get_xaxis_transform(self, which='grid'):
if which not in ['tick1', 'tick2', 'grid']:
msg = "'which' must be one of [ 'tick1' | 'tick2' | 'grid' ]"
raise ValueError(msg)
return self._xaxis_transform
Expand All @@ -542,8 +536,8 @@ def get_xaxis_text1_transform(self, pad):
def get_xaxis_text2_transform(self, pad):
return self._xaxis_text2_transform, 'center', 'center'

def get_yaxis_transform(self,which='grid'):
if which not in ['tick1','tick2','grid']:
def get_yaxis_transform(self, which='grid'):
if which not in ['tick1', 'tick2', 'grid']:
msg = "'which' must be on of [ 'tick1' | 'tick2' | 'grid' ]"
raise ValueError(msg)
return self._yaxis_transform
Expand Down Expand Up @@ -715,7 +709,7 @@ def set_theta_zero_location(self, loc, offset=0.0):
'S': np.pi * 1.5,
'SE': np.pi * 1.75,
'E': 0,
'NE': np.pi * 0.25 }
'NE': np.pi * 0.25}
return self.set_theta_offset(mapping[loc] + np.deg2rad(offset))

def set_theta_direction(self, direction):
Expand All @@ -736,7 +730,8 @@ def set_theta_direction(self, direction):
elif direction in (1, -1):
mtx[0, 0] = direction
else:
raise ValueError("direction must be 1, -1, clockwise or counterclockwise")
raise ValueError(
"direction must be 1, -1, clockwise or counterclockwise")
self._direction.invalidate()

def get_theta_direction(self):
Expand Down Expand Up @@ -802,6 +797,7 @@ def set_yscale(self, *args, **kwargs):

def set_rscale(self, *args, **kwargs):
return Axes.set_yscale(self, *args, **kwargs)

def set_rticks(self, *args, **kwargs):
return Axes.set_yticks(self, *args, **kwargs)

Expand Down Expand Up @@ -886,16 +882,17 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,

def set_xscale(self, scale, *args, **kwargs):
if scale != 'linear':
raise NotImplementedError("You can not set the xscale on a polar plot.")
raise NotImplementedError(
"You can not set the xscale on a polar plot.")

def format_coord(self, theta, r):
"""
Return a format string formatting the coordinate using Unicode
characters.
"""
if theta < 0:
theta += 2 * math.pi
theta /= math.pi
theta += 2 * np.pi
theta /= np.pi
return ('\N{GREEK SMALL LETTER THETA}=%0.3f\N{GREEK SMALL LETTER PI} '
'(%0.3f\N{DEGREE SIGN}), r=%0.3f') % (theta, theta * 180.0, r)

Expand All @@ -906,7 +903,7 @@ def get_data_ratio(self):
'''
return 1.0

### Interactive panning
# # # Interactive panning

def can_zoom(self):
"""
Expand All @@ -916,7 +913,7 @@ def can_zoom(self):
"""
return False

def can_pan(self) :
def can_pan(self):
"""
Return *True* if this axes supports the pan/zoom button functionality.

Expand All @@ -938,14 +935,13 @@ def start_pan(self, x, y, button):
mode = 'zoom'

self._pan_start = cbook.Bunch(
rmax = self.get_rmax(),
trans = self.transData.frozen(),
trans_inverse = self.transData.inverted().frozen(),
r_label_angle = self.get_rlabel_position(),
x = x,
y = y,
mode = mode
)
rmax=self.get_rmax(),
trans=self.transData.frozen(),
trans_inverse=self.transData.inverted().frozen(),
r_label_angle=self.get_rlabel_position(),
x=x,
y=y,
mode=mode)

def end_pan(self):
del self._pan_start
Expand Down Expand Up @@ -979,8 +975,6 @@ def drag_pan(self, button, key, x, y):
startt, startr = p.trans_inverse.transform_point((p.x, p.y))
t, r = p.trans_inverse.transform_point((x, y))

dr = r - startr

# Deal with r
scale = r / startr
self.set_rmax(p.rmax / scale)
Expand Down Expand Up @@ -1016,7 +1010,8 @@ def drag_pan(self, button, key, x, y):
# vertices = self.transform(vertices)

# result = np.zeros((len(vertices) * 3 - 2, 2), float)
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
# mpath.Path.code_type)
# result[0] = vertices[0]
# codes[0] = mpath.Path.MOVETO

Expand Down Expand Up @@ -1053,8 +1048,8 @@ def drag_pan(self, button, key, x, y):

# result[3::3] = p1

# print vertices[-2:]
# print result[-2:]
# print(vertices[-2:])
# print(result[-2:])

# return mpath.Path(result, codes)

Expand All @@ -1068,12 +1063,13 @@ def drag_pan(self, button, key, x, y):
# maxtd = td.max()
# interpolate = np.ceil(maxtd / halfpi)

# print "interpolate", interpolate
# print("interpolate", interpolate)
# if interpolate > 1.0:
# vertices = self.interpolate(vertices, interpolate)

# result = np.zeros((len(vertices) * 3 - 2, 2), float)
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ), mpath.Path.code_type)
# codes = mpath.Path.CURVE4 * np.ones((len(vertices) * 3 - 2, ),
# mpath.Path.code_type)
# result[0] = vertices[0]
# codes[0] = mpath.Path.MOVETO

Expand All @@ -1095,16 +1091,19 @@ def drag_pan(self, button, key, x, y):

# result[1::3, 0] = t0 + (tkappa * td_scaled)
# result[1::3, 1] = r0*hyp_kappa
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled) # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)
# # result[1::3, 1] = r0 / np.cos(tkappa * td_scaled)
# # np.sqrt(r0*r0 + ravg_kappa*ravg_kappa)

# result[2::3, 0] = t1 - (tkappa * td_scaled)
# result[2::3, 1] = r1*hyp_kappa
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled) # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)
# # result[2::3, 1] = r1 / np.cos(tkappa * td_scaled)
# # np.sqrt(r1*r1 + ravg_kappa*ravg_kappa)

# result[3::3, 0] = t1
# result[3::3, 1] = r1

# print vertices[:6], result[:6], t0[:6], t1[:6], td[:6], td_scaled[:6], tkappa
# print(vertices[:6], result[:6], t0[:6], t1[:6], td[:6],
# td_scaled[:6], tkappa)
# result = self.transform(result)
# return mpath.Path(result, codes)
# transform_path_non_affine = transform_path
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pep8ignore =
matplotlib/backend_bases.py E225 E501 E712
matplotlib/projections/__init__.py E302
matplotlib/projections/geo.py E203 E221 E231 E261 E302 E402 E501 E502
matplotlib/projections/polar.py E202 E203 E221 E231 E251 E301 E402 E501
matplotlib/sphinxext/mathmpl.py E302
matplotlib/sphinxext/only_directives.py E302
matplotlib/sphinxext/plot_directive.py E261 E301 E302 E401 E402 E501
Expand Down