Thanks to visit codestin.com
Credit goes to github.com

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
Next Next commit
Fixed polar resolution handling. All tests passing (9 known fails).
  • Loading branch information
Phil Elson authored and pelson committed Jun 11, 2012
commit 8a3bdfc9f2593003921c7cfdcf2cee7c2cbb21de
7 changes: 7 additions & 0 deletions lib/matplotlib/projections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ def process_projection_requirements(figure, *args, **kwargs):
projection)
projection = 'polar'

# ensure that the resolution keyword is always put into the key
# for polar plots [so that the result of
# plt.subplot(111, projection='polar') can be found with
# plt.gca(projection='polar', resolution=1)]
if projection == 'polar':
kwargs.setdefault('resolution', 1)

if isinstance(projection, basestring) or projection is None:
projection_class = get_projection_class(projection)
elif hasattr(projection, '_as_mpl_axes'):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ def __init__(self, *args, **kwargs):
each pair of data points. Set to 1 to disable
interpolation.
"""

self.resolution = kwargs.pop('resolution', None)
self._rpad = 0.05
self.resolution = kwargs.pop('resolution', 1)
self._default_theta_offset = kwargs.pop('theta_offset', 0)
self._default_theta_direction = kwargs.pop('theta_direction', 1)

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,7 @@ def polar(*args, **kwargs):
interpolate between each pair of points. The default is 1,
which disables interpolation.
"""
resolution = kwargs.pop('resolution', None)
resolution = kwargs.pop('resolution', 1)
ax = gca(polar=True, resolution=resolution)
ret = ax.plot(*args, **kwargs)
draw_if_interactive()
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def test_const_xy():
plt.subplot( 313 )
plt.plot( np.ones( (10,) ), np.ones( (10,) ), 'o' )


@image_comparison(baseline_images=['polar_wrap_180',
'polar_wrap_360',
])
Expand All @@ -273,10 +274,11 @@ def test_polar_wrap():
fig = plt.figure()

plt.subplot(111, polar=True)

plt.polar( [179*D2R, -179*D2R], [0.2, 0.1], "b.-" )
plt.polar( [179*D2R, 181*D2R], [0.2, 0.1], "g.-" )
plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] )

assert len(fig.axes) == 1, 'More than one polar axes created.'
fig = plt.figure()

plt.subplot( 111, polar=True)
Expand All @@ -285,6 +287,7 @@ def test_polar_wrap():
plt.polar( [358*D2R, 2*D2R], [0.2, 0.1], "r.-" )
plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] )


@image_comparison(baseline_images=['polar_units', 'polar_units_2'],
freetype_version=('2.4.5', '2.4.9'))
def test_polar_units():
Expand Down