本文整理匯總了Python中matplotlib.pyplot.polar方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.polar方法的具體用法?Python pyplot.polar怎麽用?Python pyplot.polar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.polar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_polar_wrap
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_wrap():
D2R = np.pi / 180.0
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)
plt.polar([2*D2R, -2*D2R], [0.2, 0.1], "b.-")
plt.polar([2*D2R, 358*D2R], [0.2, 0.1], "g.-")
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])
示例2: test_markevery_polar
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_markevery_polar():
cases = [None,
8,
(30, 8),
[16, 24, 30], [0,-1],
slice(100, 200, 3),
0.1, 0.3, 1.5,
(0.0, 0.1), (0.45, 0.1)]
cols = 3
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
r = np.linspace(0, 3.0, 200)
theta = 2 * np.pi * r
for i, case in enumerate(cases):
row = (i // cols)
col = i % cols
plt.subplot(gs[row, col], polar = True)
plt.title('markevery=%s' % str(case))
plt.plot(theta, r, 'o', ls='-', ms=4, markevery=case)
示例3: test_polar_annotations
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_annotations():
# you can specify the xypoint and the xytext in different
# positions and coordinate systems, and optionally turn on a
# connecting line and mark the point with a marker. Annotations
# work on polar axes too. In the example below, the xy point is
# in native coordinates (xycoords defaults to 'data'). For a
# polar axes, this is in (theta, radius) space. The text in this
# example is placed in the fractional figure coordinate system.
# Text keyword args like horizontal and vertical alignment are
# respected
# Setup some data
r = np.arange(0.0, 1.0, 0.001)
theta = 2.0 * 2.0 * np.pi * r
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
line, = ax.plot((0, 0), (0, 1), color="#0000ff", lw=1)
ind = 800
thisr, thistheta = r[ind], theta[ind]
ax.plot([thistheta], [thisr], 'o')
ax.annotate('a polar annotation',
xy=(thistheta, thisr), # theta, radius
xytext=(0.05, 0.05), # fraction, fraction
textcoords='figure fraction',
arrowprops=dict(facecolor='black', shrink=0.05),
horizontalalignment='left',
verticalalignment='baseline',
)
示例4: test_polar_coord_annotations
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_coord_annotations():
# You can also use polar notation on a catesian axes. Here the
# native coordinate system ('data') is cartesian, so you need to
# specify the xycoords and textcoords as 'polar' if you want to
# use (theta, radius)
from matplotlib.patches import Ellipse
el = Ellipse((0, 0), 10, 20, facecolor='r', alpha=0.5)
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.add_artist(el)
el.set_clip_box(ax.bbox)
ax.annotate('the top',
xy=(np.pi/2., 10.), # theta, radius
xytext=(np.pi/3, 20.), # theta, radius
xycoords='polar',
textcoords='polar',
arrowprops=dict(facecolor='black', shrink=0.05),
horizontalalignment='left',
verticalalignment='baseline',
clip_on=True, # clip to the axes bounding box
)
ax.set_xlim(-20, 20)
ax.set_ylim(-20, 20)
示例5: test_polar_units
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_units():
import matplotlib.testing.jpl_units as units
from nose.tools import assert_true
units.register()
pi = np.pi
deg = units.UnitDbl(1.0, "deg")
km = units.UnitDbl(1.0, "km")
x1 = [pi/6.0, pi/4.0, pi/3.0, pi/2.0]
x2 = [30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg]
y1 = [1.0, 2.0, 3.0, 4.0]
y2 = [4.0, 3.0, 2.0, 1.0]
fig = plt.figure()
plt.polar(x2, y1, color="blue")
# polar(x2, y1, color = "red", xunits="rad")
# polar(x2, y2, color = "green")
fig = plt.figure()
# make sure runits and theta units work
y1 = [y*km for y in y1]
plt.polar(x2, y1, color="blue", thetaunits="rad", runits="km")
assert_true(isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter))
示例6: test_polar_rmin
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_rmin():
r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.plot(theta, r)
ax.set_rmax(2.0)
ax.set_rmin(0.5)
示例7: test_polar_rlabel_position
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_rlabel_position():
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
ax.set_rlabel_position(315)
示例8: test_polar_annotations
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_annotations():
# you can specify the xypoint and the xytext in different
# positions and coordinate systems, and optionally turn on a
# connecting line and mark the point with a marker. Annotations
# work on polar axes too. In the example below, the xy point is
# in native coordinates (xycoords defaults to 'data'). For a
# polar axes, this is in (theta, radius) space. The text in this
# example is placed in the fractional figure coordinate system.
# Text keyword args like horizontal and vertical alignment are
# respected
# Setup some data
r = np.arange(0.0, 1.0, 0.001)
theta = 2.0 * 2.0 * np.pi * r
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
line, = ax.plot((0, 0), (0, 1), color="#0000ff", lw=1)
ind = 800
thisr, thistheta = r[ind], theta[ind]
ax.plot([thistheta], [thisr], 'o')
ax.annotate('a polar annotation',
xy=(thistheta, thisr), # theta, radius
xytext=(0.05, 0.05), # fraction, fraction
textcoords='figure fraction',
arrowprops=dict(facecolor='black', shrink=0.05),
horizontalalignment='left',
verticalalignment='baseline',
)
ax.tick_params(axis='x', tick1On=True, tick2On=True, direction='out')
示例9: test_polar_alignment
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_alignment():
'''
Test that changing the vertical/horizontal alignment of a polar graph
works as expected '''
ranges = [(0, 5), (0, 5)]
angles = np.arange(0, 360, 90)
levels = 5
fig = plt.figure()
figureSize = [0.1, 0.1, 0.8, 0.8]
horizontal = fig.add_axes(figureSize, polar=True, label='horizontal')
vertical = fig.add_axes(figureSize, polar=True, label='vertical')
axes = [horizontal, vertical]
horizontal.set_thetagrids(angles)
vertical.patch.set_visible(False)
for i in range(2):
grid = np.linspace(*ranges[i], num=levels)
gridValues = [0, 0.2, 0.4, 0.6, 0.8, 1]
axes[i].set_rgrids(gridValues, angle=angles[i],
horizontalalignment='left',
verticalalignment='top')
示例10: test_polar_wrap
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_wrap():
fig = plt.figure()
plt.subplot(111, polar=True)
plt.polar(np.deg2rad([179, -179]), [0.2, 0.1], "b.-")
plt.polar(np.deg2rad([179, 181]), [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)
plt.polar(np.deg2rad([2, -2]), [0.2, 0.1], "b.-")
plt.polar(np.deg2rad([2, 358]), [0.2, 0.1], "g.-")
plt.polar(np.deg2rad([358, 2]), [0.2, 0.1], "r.-")
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])
示例11: test_polar_units
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_units():
import matplotlib.testing.jpl_units as units
units.register()
pi = np.pi
deg = units.deg
km = units.km
x1 = [pi/6.0, pi/4.0, pi/3.0, pi/2.0]
x2 = [30.0*deg, 45.0*deg, 60.0*deg, 90.0*deg]
y1 = [1.0, 2.0, 3.0, 4.0]
y2 = [4.0, 3.0, 2.0, 1.0]
fig = plt.figure()
plt.polar(x2, y1, color="blue")
# polar(x2, y1, color = "red", xunits="rad")
# polar(x2, y2, color = "green")
fig = plt.figure()
# make sure runits and theta units work
y1 = [y*km for y in y1]
plt.polar(x2, y1, color="blue", thetaunits="rad", runits="km")
assert isinstance(plt.gca().get_xaxis().get_major_formatter(),
units.UnitDblFormatter)
示例12: test_polar_negative_rmin
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_negative_rmin():
r = np.arange(-3.0, 0.0, 0.01)
theta = 2*np.pi*r
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.plot(theta, r)
ax.set_rmax(0.0)
ax.set_rmin(-3.0)
示例13: test_polar_rorigin
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_rorigin():
r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.plot(theta, r)
ax.set_rmax(2.0)
ax.set_rmin(0.5)
ax.set_rorigin(0.0)
示例14: test_polar_theta_position
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_theta_position():
r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
ax.plot(theta, r)
ax.set_theta_zero_location("NW", 30)
ax.set_theta_direction('clockwise')
示例15: test_polar_rlabel_position
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import polar [as 別名]
def test_polar_rlabel_position():
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
ax.set_rlabel_position(315)
ax.tick_params(rotation='auto')