Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
efiring merged 14 commits intomatplotlib:masterfromQuLogic:polar-limits
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
24cd817
ENH: Add an "arc" spine type.
QuLogicJul 17, 2015
52ab847
FIX: Allow negative radii in RadialLocator and polar grids.
QuLogicJul 14, 2015
3809803
BUG: Ensure polar radial limits are nonsingular.
QuLogicJul 17, 2015
0b6cc58
ENH: Don't round degree digits when zoomed on PolarAxes.
QuLogicJul 17, 2015
2b77dbc
MNT: Standardize import in polar projection.
QuLogicJul 19, 2015
2b33d7f
MNT: Use transforms for polar direction&offset.
QuLogicJul 19, 2015
cbaee4a
ENH: Allow setting an "origin" radius for PolarAxes.
QuLogicJul 20, 2015
202f40f
ENH: Allow setting angle limits on PolarAxes.
QuLogicJul 31, 2015
b47ccba
ENH: Allow offsetting PolarAxes' zero location.
QuLogicJul 21, 2015
d549014
STY: PEP8 the rest of PolarAxes code.
QuLogicJul 21, 2015
b85c48c
DOC: Add what's new for polar axes.
QuLogicJul 22, 2015
d67a7be
Use text transform for polar ticks also.
QuLogicAug 5, 2017
734da0f
Use ordered dict for polar spines.
QuLogicAug 16, 2017
7b998e1
Update polar test images.
QuLogicAug 16, 2017
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
37 changes: 37 additions & 0 deletionsdoc/users/next_whats_new/2015-10-31_polar_limits.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
Enhancements to polar plot
--------------------------

The polar axes transforms have been greatly re-factored to allow for more
customization of view limits and tick labelling. Additional options for view
limits allow for creating an annulus, a sector, or some combination of the two.

The :meth:`~matplotlib.axes.projections.polar.PolarAxes.set_rorigin` method may
be used to provide an offset to the minimum plotting radius, producing an
annulus.

The :meth:`~matplotlib.projections.polar.PolarAxes.set_theta_zero_location` now
has an optional :code:`offset` argument. This argument may be used to further
specify the zero location based on the given anchor point.

.. figure:: ../../gallery/pie_and_polar_charts/images/sphx_glr_polar_scatter_001.png
:target: ../../gallery/pie_and_polar_charts/polar_scatter.html
:align: center
:scale: 50

Polar Offset Demo

The :meth:`~matplotlib.axes.projections.polar.PolarAxes.set_thetamin` and
:meth:`~matplotlib.axes.projections.polar.PolarAxes.set_thetamax` methods may
be used to limit the range of angles plotted, producing sectors of a circle.

.. figure:: ../../gallery/pie_and_polar_charts/images/sphx_glr_polar_scatter_002.png
:target: ../../gallery/pie_and_polar_charts/polar_scatter.html
:align: center
:scale: 50

Polar Sector Demo

Previous releases allowed plots containing negative radii for which the
negative values are simply used as labels, and the real radius is shifted by
the configured minimum. This release also allows negative radii to be used for
grids and ticks, which were previously silently ignored.
12 changes: 8 additions & 4 deletionsexamples/api/radar_chart.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,11 +37,10 @@ def radar_factory(num_vars, frame='circle'):
"""
# calculate evenly-spaced axis angles
theta = np.linspace(0, 2*np.pi, num_vars, endpoint=False)
# rotate theta such that the first axis is at the top
theta += np.pi/2

def draw_poly_patch(self):
verts = unit_poly_verts(theta)
# rotate theta such that the first axis is at the top
verts = unit_poly_verts(theta + np.pi / 2)
return plt.Polygon(verts, closed=True, edgecolor='k')

def draw_circle_patch(self):
Expand All@@ -60,6 +59,11 @@ class RadarAxes(PolarAxes):
# define draw_frame method
draw_patch = patch_dict[frame]

def __init__(self, *args, **kwargs):
super(RadarAxes, self).__init__(*args, **kwargs)
# rotate plot such that the first axis is at the top
self.set_theta_zero_location('N')

def fill(self, *args, **kwargs):
"""Override fill so that line is closed by default"""
closed = kwargs.pop('closed', True)
Expand DownExpand Up@@ -93,7 +97,7 @@ def _gen_axes_spines(self):

# spine_type must be 'left', 'right', 'top', 'bottom', or `circle`.
spine_type = 'circle'
verts = unit_poly_verts(theta)
verts = unit_poly_verts(theta + np.pi / 2)
# close off polygon by repeating first vertex
verts.append(verts[0])
path = Path(verts)
Expand Down
34 changes: 31 additions & 3 deletionsexamples/pie_and_polar_charts/polar_scatter.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,6 @@
Scatter plot on polar axis
==========================

Demo of scatter plot on a polar axis.

Size increases radially in this example and color increases with angle
(just to verify the symbols are being scattered correctly).
"""
Expand All@@ -22,7 +20,37 @@
area = 200 * r**2
colors = theta

ax = plt.subplot(111, projection='polar')
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

###############################################################################
# Scatter plot on polar axis, with offset origin
# ----------------------------------------------
#
# The main difference with the previous plot is the configuration of the origin
# radius, producing an annulus. Additionally, the theta zero location is set to
# rotate the plot.

fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

ax.set_rorigin(-2.5)
ax.set_theta_zero_location('W', offset=10)

###############################################################################
# Scatter plot on polar axis confined to a sector
# -----------------------------------------------
#
# The main difference with the previous plots is the configuration of the
# theta start and end limits, producing a sector instead of a full circle.

fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

ax.set_thetamin(45)
ax.set_thetamax(135)

plt.show()
Loading

[8]ページ先頭

©2009-2025 Movatter.jp