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

Skip to content

Commit 47af03d

Browse files
committed
added binary colormap and barcode demo
svn path=/trunk/matplotlib/; revision=3018
1 parent f8deccd commit 47af03d

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2007-02-13 Added barcode demo- JDH
2+
3+
2007-02-13 Added binary colormap to cm - JDH
4+
15
2007-02-13 Added twiny to pylab - JDH
26

37
2007-02-12 Moved data files into lib/matplotlib so that setuptools'

examples/barcode_demo.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pylab import figure, show, cm, nx
2+
3+
axprops = dict(xticks=[], yticks=[])
4+
barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest')
5+
6+
fig = figure()
7+
8+
# a vertical barcode
9+
x = nx.mlab.rand(500,1)
10+
x[x>0.8] = 1.
11+
x[x<=0.8] = 0.
12+
ax = fig.add_axes([0.1, 0.3, 0.1, 0.6], **axprops)
13+
ax.imshow(x, **barprops)
14+
15+
16+
# a horizontal barcode
17+
x = nx.mlab.rand(1,500)
18+
x[x>0.8] = 1.
19+
x[x<=0.8] = 0.
20+
ax = fig.add_axes([0.3, 0.1, 0.6, 0.1], **axprops)
21+
ax.imshow(x, **barprops)
22+
23+
fig.savefig('barcode.png', dpi=100)
24+
show()
25+

lib/matplotlib/_cm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
from matplotlib import rcParams, colors
1313
LUTSIZE = rcParams['image.lut']
1414

15-
15+
_binary_data = {
16+
'red' : ((0., 1., 1.), (1., 0., 0.)),
17+
'green': ((0., 1., 1.), (1., 0., 0.)),
18+
'blue' : ((0., 1., 1.), (1., 0., 0.))
19+
}
1620

1721

1822
_bone_data = {'red': ((0., 0., 0.),(1.0, 1.0, 1.0)),
@@ -376,6 +380,7 @@
376380

377381
autumn = colors.LinearSegmentedColormap('autumn', _autumn_data, LUTSIZE)
378382
bone = colors.LinearSegmentedColormap('bone ', _bone_data, LUTSIZE)
383+
binary = colors.LinearSegmentedColormap('binary ', _binary_data, LUTSIZE)
379384
cool = colors.LinearSegmentedColormap('cool', _cool_data, LUTSIZE)
380385
copper = colors.LinearSegmentedColormap('copper', _copper_data, LUTSIZE)
381386
flag = colors.LinearSegmentedColormap('flag', _flag_data, LUTSIZE)
@@ -395,6 +400,7 @@
395400
datad = {
396401
'autumn': _autumn_data,
397402
'bone': _bone_data,
403+
'binary': _binary_data,
398404
'cool': _cool_data,
399405
'copper': _copper_data,
400406
'flag': _flag_data,

lib/matplotlib/axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2554,7 +2554,7 @@ def xcorr(self, x, y, normed=False, detrend=detrend_none, **kwargs):
25542554
25552555
data are plotted as plot(lags, c, **kwargs)
25562556
2557-
return value is lags, c, line where lags are a length
2557+
Return value is (lags, c, line) where lags are a length
25582558
2*len(x)+1 lag vector, c is the 2*len(x)+1 cross correlation
25592559
vector, and line is a Line2D instance returned by plot. The
25602560
default linestyle is None and the default marker is 'o',

0 commit comments

Comments
 (0)