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

Skip to content

Commit 2df6609

Browse files
committed
diverging colormaps with centered norms
1 parent f16b15f commit 2df6609

6 files changed

Lines changed: 11 additions & 10 deletions

File tree

examples/pylab_examples/griddata_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
zi = griddata(x,y,z,xi,yi,interp='linear')
1717
# contour the gridded data, plotting dots at the nonuniform data points.
1818
CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
19-
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
19+
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.rainbow, vmax=abs(zi).max(), vmin=-abs(zi).max())
2020
plt.colorbar() # draw colorbar
2121
# plot data points.
2222
plt.scatter(x,y,marker='o',c='b',s=5,zorder=10)

examples/pylab_examples/hexbin_demo2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
gridsize=30
4040

4141
plt.subplot(211)
42-
plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True)
42+
plt.hexbin(x,y, C=z, gridsize=gridsize, marginals=True, cmap=cm.RdBu, vmax=abs(z).max(), vmin=-abs(z).max()) # NEEDS NORM
4343
plt.axis([xmin, xmax, ymin, ymax])
4444
cb = plt.colorbar()
4545
cb.set_label('mean value')
4646

4747

4848
plt.subplot(212)
49-
plt.hexbin(x,y, gridsize=gridsize)
49+
plt.hexbin(x,y, gridsize=gridsize, cmap=cm.Blues_r)
5050
plt.axis([xmin, xmax, ymin, ymax])
5151
cb = plt.colorbar()
5252
cb.set_label('N observations')

examples/pylab_examples/image_demo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
1212
Z = Z2-Z1 # difference of Gaussians
1313

14-
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.gray,
15-
origin='lower', extent=[-3,3,-3,3])
14+
im = plt.imshow(Z, interpolation='bilinear', cmap=cm.RdYlGn,
15+
origin='lower', extent=[-3,3,-3,3],
16+
vmax=abs(Z).max(), vmin=-abs(Z).max())
1617

1718
plt.show()
1819

examples/pylab_examples/pcolor_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def func3(x,y):
1919
X,Y = meshgrid(x, y)
2020

2121
Z = func3(X, Y)
22-
pcolor(X, Y, Z)
22+
pcolor(X, Y, Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
2323
colorbar()
2424
axis([-3,3,-3,3])
2525

examples/pylab_examples/pcolor_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def func3(x,y):
2020

2121

2222
ax = subplot(111)
23-
im = imshow(Z, cmap=cm.jet)
23+
im = imshow(Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
2424
#im.set_interpolation('nearest')
2525
#im.set_interpolation('bicubic')
2626
im.set_interpolation('bilinear')

examples/pylab_examples/poormans_contour.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
1919
Z = Z2 - Z1 # difference of Gaussians
2020

21-
cmap = cm.get_cmap('jet', 10) # 10 discrete colors
22-
23-
im = imshow(Z, cmap=cmap, interpolation='bilinear')
21+
cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors
22+
#NORM
23+
im = imshow(Z, cmap=cmap, interpolation='bilinear', vmax=abs(Z).max(), vmin=-abs(Z).max())
2424
axis('off')
2525
colorbar()
2626

0 commit comments

Comments
 (0)