8000 DOC: Change colormaps for examples (showcase different types, discourage 'jet') by endolith · Pull Request #921 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

DOC: Change colormaps for examples (showcase different types, discourage 'jet') #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 24, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
diverging colormaps with centered norms
  • Loading branch information
endolith committed Jun 5, 2012
commit 2df6609940882d914b5476311db3e0999408dfa1
2 changes: 1 addition & 1 deletion examples/pylab_examples/griddata_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
zi = griddata(x,y,z,xi,yi,interp='linear')
# contour the gridded data, plotting dots at the nonuniform data points.
CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.rainbow, vmax=abs(zi).max(), vmin=-abs(zi).max())
plt.colorbar() # draw colorbar
# plot data points.
plt.scatter(x,y,marker='o',c='b',s=5,zorder=10)
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/hexbin_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
gridsize=30

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


plt.subplot(212)
plt.hexbin(x,y, gridsize=gridsize)
plt.hexbin(x,y, gridsize=gridsize, cmap=cm.Blues_r)
plt.axis([xmin, xmax, ymin, ymax])
cb = plt.colorbar()
cb.set_label('N observations')
Expand Down
5 changes: 3 additions & 2 deletions examples/pylab_examples/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z2-Z1 # difference of Gaussians

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

plt.show()

2 changes: 1 addition & 1 deletion examples/pylab_examples/pcolor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def func3(x,y):
X,Y = meshgrid(x, y)

Z = func3(X, Y)
pcolor(X, Y, Z)
pcolor(X, Y, Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
colorbar()
axis([-3,3,-3,3])

Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/pcolor_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def func3(x,y):


ax = subplot(111)
im = imshow(Z, cmap=cm.jet)
im = imshow(Z, cmap=cm.RdBu, vmax=abs(Z).max(), vmin=-abs(Z).max())
#im.set_interpolation('nearest')
#im.set_interpolation('bicubic')
im.set_interpolation('bilinear')
Expand Down
6 changes: 3 additions & 3 deletions examples/pylab_examples/poormans_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = Z2 - Z1 # difference of Gaussians

cmap = cm.get_cmap('jet', 10) # 10 discrete colors
51F5
im = imshow(Z, cmap=cmap, interpolation='bilinear')
cmap = cm.get_cmap('PiYG', 11) # 11 discrete colors
#NORM
im = imshow(Z, cmap=cmap, interpolation='bilinear', vmax=abs(Z).max(), vmin=-abs(Z).max())
axis('off')
colorbar()

Expand Down
0