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

Skip to content

Commit de74e56

Browse files
committed
Merged revisions 8714-8715 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v1_0_maint ........ r8714 | mdboom | 2010-09-21 15:18:48 -0500 (Tue, 21 Sep 2010) | 2 lines Bug # ........ r8715 | jdh2358 | 2010-09-22 07:46:38 -0500 (Wed, 22 Sep 2010) | 1 line added Bartosz Telenczuk's artist demo ........ svn path=/trunk/matplotlib/; revision=8716
2 parents f8e4c6c + e040267 commit de74e56

3 files changed

Lines changed: 146 additions & 4 deletions

File tree

examples/api/artist_demo.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
"""
2+
Show examples of matplotlib artists
3+
http://matplotlib.sourceforge.net/api/artist_api.html
4+
5+
Several examples of standard matplotlib graphics primitives (artists)
6+
are drawn using matplotlib API. Full list of artists and the
7+
documentation is available at
8+
http://matplotlib.sourceforge.net/api/artist_api.html
9+
10+
Copyright (c) 2010, Bartosz Telenczuk
11+
12+
License: This work is licensed under the BSD. A copy should be
13+
included with this source code, and is also available at
14+
http://www.opensource.org/licenses/bsd-license.php
15+
"""
16+
17+
18+
import numpy as np
19+
import matplotlib.pyplot as plt
20+
import matplotlib
21+
from matplotlib.collections import PatchCollection
22+
import matplotlib.path as mpath
23+
import matplotlib.patches as mpatches
24+
import matplotlib.lines as mlines
25+
26+
font = "sans-serif"
27+
fig = plt.figure(figsize=(5,5))
28+
ax = plt.axes([0,0,1,1])
29+
30+
# create 3x3 grid to plot the artists
31+
pos = np.mgrid[0.2:0.8:3j, 0.2:0.8:3j].reshape(2, -1)
32+
33+
patches = []
34+
35+
# add a circle
36+
art = mpatches.Circle(pos[:,0], 0.1,ec="none")
37+
patches.append(art)
38+
plt.text(pos[0,0], pos[1,0]-0.15, "Circle", ha="center",
39+
family=font, size=14)
40+
41+
# add a rectangle
42+
art = mpatches.Rectangle(pos[:,1] - np.array([0.025, 0.05]), 0.05, 0.1,
43+
ec="none")
44+
patches.append(art)
45+
plt.text(pos[0,1], pos[1,1]-0.15, "Rectangle", ha="center",
46+
family=font, size=14)
47+
48+
# add a wedge
49+
wedge = mpatches.Wedge(pos[:,2], 0.1, 30, 270, ec="none")
50+
patches.append(wedge)
51+
plt.text(pos[0,2], pos[1,2]-0.15, "Wedge", ha="center",
52+
family=font, size=14)
53+
54+
# add a Polygon
55+
polygon = mpatches.RegularPolygon(pos[:,3], 5, 0.1)
56+
patches.append(polygon)
57+
plt.text(pos[0,3], pos[1,3]-0.15, "Polygon", ha="center",
58+
family=font, size=14)
59+
60+
#add an ellipse
61+
ellipse = mpatches.Ellipse(pos[:,4], 0.2, 0.1)
62+
patches.append(ellipse)
63+
plt.text(pos[0,4], pos[1,4]-0.15, "Ellipse", ha="center",
64+
family=font, size=14)
65+
66+
#add an arrow
67+
arrow = mpatches.Arrow(pos[0,5]-0.05, pos[1,5]-0.05, 0.1, 0.1, width=0.1)
68+
patches.append(arrow)
69+
plt.text(pos[0,5], pos[1,5]-0.15, "Arrow", ha="center",
70+
family=font, size=14)
71+
72+
# add a path patch
73+
Path = mpath.Path
74+
verts = np.array([
75+
(0.158, -0.257),
76+
(0.035, -0.11),
77+
(-0.175, 0.20),
78+
(0.0375, 0.20),
79+
(0.085, 0.115),
80+
(0.22, 0.32),
81+
(0.3, 0.005),
82+
(0.20, -0.05),
83+
(0.158, -0.257),
84+
])
85+
verts = verts-verts.mean(0)
86+
codes = [Path.MOVETO,
87+
Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.LINETO,
88+
Path.CURVE4, Path.CURVE4, Path.CURVE4, Path.CLOSEPOLY]
89+
90+
path = mpath.Path(verts/2.5+pos[:,6], codes)
91+
patch = mpatches.PathPatch(path)
92+
patches.append(patch)
93+
plt.text(pos[0,6], pos[1,6]-0.15, "PathPatch", ha="center",
94+
family=font, size=14)
95+
96+
# add a fancy box
97+
fancybox = mpatches.FancyBboxPatch(
98+
pos[:,7]-np.array([0.025, 0.05]), 0.05, 0.1,
99+
boxstyle=mpatches.BoxStyle("Round", pad=0.02))
100+
patches.append(fancybox)
101+
plt.text(pos[0,7], pos[1,7]-0.15, "FancyBoxPatch", ha="center",
102+
family=font, size=14)
103+
104+
# add a line
105+
x,y = np.array([[-0.06, 0.0, 0.1], [0.05,-0.05, 0.05]])
106+
line = mlines.Line2D(x+pos[0,8], y+pos[1,8], lw=5.,
107+
alpha=0.4)
108+
plt.text(pos[0,8], pos[1,8]-0.15, "Line2D", ha="center",
109+
family=font, size=14)
110+
111+
colors = 100*np.random.rand(len(patches))
112+
collection = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)
113+
collection.set_array(np.array(colors))
114+
ax.add_collection(collection)
115+
ax.add_line(line)
116+
ax.set_xticks([])
117+
ax.set_yticks([])
118+
119+
plt.show()

lib/matplotlib/tri/_tri.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@ void TriContourGenerator::clear_visited_flags(bool include_boundaries)
559559
// Clear _boundaries_visited.
560560
for (BoundariesVisited::iterator it = _boundaries_visited.begin();
561561
it != _boundaries_visited.end(); ++it)
562-
fill(it->begin(), it->end(), false);
562+
std::fill(it->begin(), it->end(), false);
563563

564564
// Clear _boundaries_used.
565-
fill(_boundaries_used.begin(), _boundaries_used.end(), false);
565+
std::fill(_boundaries_used.begin(), _boundaries_used.end(), false);
566566
}
567567
}
568568

src/mplutils.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* mplutils.h --
1+
/* mplutils.h --
22
*
33
* $Header$
44
* $Log$
@@ -20,7 +20,7 @@
2020
void _VERBOSE(const std::string&);
2121

2222

23-
#undef CLAMP
23+
#undef CLAMP
2424
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
2525

2626
#undef MAX
@@ -45,4 +45,27 @@ public :
4545
friend std::ostream &operator <<(std::ostream &, const Printf &);
4646
};
4747

48+
#if defined(_MSC_VER) && (_MSC_VER == 1400)
49+
50+
/* Required by libpng and zlib */
51+
#pragma comment(lib, "bufferoverflowU")
52+
53+
/* std::max and std::min are missing in Windows Server 2003 R2
54+
Platform SDK compiler. See matplotlib bug #3067191 */
55+
namespace std {
56+
57+
template <class T> inline T max(const T& a, const T& b)
58+
{
59+
return (a > b) ? a : b;
60+
}
61+
62+
template <class T> inline T min(const T& a, const T& b)
63+
{
64+
return (a < b) ? a : b;
65+
}
66+
67+
}
68+
69+
#endif
70+
4871
#endif

0 commit comments

Comments
 (0)