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

Skip to content

Commit 491f6cd

Browse files
committed
added polar bar char demo
svn path=/trunk/matplotlib/; revision=3254
1 parent 6712ebe commit 491f6cd

3 files changed

Lines changed: 25 additions & 42 deletions

File tree

examples/polar_bar.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
3+
import matplotlib.numerix as nx
4+
from matplotlib.mlab import linspace
5+
import matplotlib.cm as cm
6+
from pylab import figure, show, rc
7+
8+
9+
# force square figure and square axes looks better for polar, IMO
10+
fig = figure(figsize=(8,8))
11+
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)
12+
13+
N = 20
14+
theta = nx.arange(0.0, 2*nx.pi, 2*nx.pi/N)
15+
radii = 10*nx.mlab.rand(N)
16+
width = nx.pi/4*nx.mlab.rand(N)
17+
bars = ax.bar(theta, radii, width=width)
18+
for r,bar in zip(radii, bars):
19+
bar.set_facecolor( cm.jet(r/10.))
20+
bar.set_alpha(0.5)
21+
show()

examples/polar_legend.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,4 @@
11
#!/usr/bin/env python
2-
#
3-
# matplotlib now has a PolarAxes class and a polar function in the
4-
# matplotlib interface. This is considered alpha and the interface
5-
# may change as we work out how polar axes should best be integrated
6-
#
7-
# The only function that has been tested on polar axes is "plot" (the
8-
# pylab interface function "polar" calls ax.plot where ax is a
9-
# PolarAxes) -- other axes plotting functions may work on PolarAxes
10-
# but haven't been tested and may need tweaking.
11-
#
12-
# you can get get a PolarSubplot instance by doing, for example
13-
#
14-
# subplot(211, polar=True)
15-
#
16-
# or a PolarAxes instance by doing
17-
# axes([left, bottom, width, height], polar=True)
18-
#
19-
# The view limits (eg xlim and ylim) apply to the lower left and upper
20-
# right of the rectangular box that surrounds to polar axes. Eg if
21-
# you have
22-
#
23-
# r = arange(0,1,0.01)
24-
# theta = 2*pi*r
25-
#
26-
# the lower left corner is 5/4pi, sqrt(2) and the
27-
# upper right corner is 1/4pi, sqrt(2)
28-
#
29-
# you could change the radial bounding box (zoom out) by setting the
30-
# ylim (radial coordinate is the second argument to the plot command,
31-
# as in matlab(TM), though this is not advised currently because it is not
32-
# clear to me how the axes should behave in the change of view limits.
33-
# Please advise me if you have opinions. Likewise, the pan/zoom
34-
# controls probably do not do what you think they do and are better
35-
# left alone on polar axes. Perhaps I will disable them for polar
36-
# axes unless we come up with a meaningful, useful and functional
37-
# implementation for them.
38-
#
39-
# See the pylab rgrids and thetagrids functions for
40-
# information on how to customize the grid locations and labels
412

423
import matplotlib.numerix as nx
434
from pylab import figure, show, rc

lib/matplotlib/axes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5280,7 +5280,8 @@ def cla(self):
52805280
self.artists = []
52815281
self.collections = []
52825282
self.texts = [] # text in axis coords
5283-
5283+
self.legend_ = None
5284+
52845285
self.grid(self._gridOn)
52855286
self.title = Text(
52865287
x=0.5, y=1.05, text='',
@@ -5556,8 +5557,8 @@ def draw(self, renderer):
55565557
l.set_clip_path(clippath)
55575558
l.draw(renderer)
55585559

5559-
for line in self.lines:
5560-
line.set_clip_path(clippath)
5560+
for a in self.lines:
5561+
a.set_clip_path(clippath)
55615562

55625563
artists = []
55635564
artists.extend(self.lines)

0 commit comments

Comments
 (0)