Skip to content

Instantly share code, notes, and snippets.

@avishekrk
Created April 25, 2016 22:58
Show Gist options
  • Save avishekrk/2921910c1077bf56154cef17515321e3 to your computer and use it in GitHub Desktop.
Save avishekrk/2921910c1077bf56154cef17515321e3 to your computer and use it in GitHub Desktop.
Make a vertical colorbar
import pylab as pl
import numpy as np
pl.rcParams.update({'font.size': 22})
a = np.array([[-0.5,1.75]])
pl.figure(figsize=(4.0, 16))
img = pl.imshow(a,cmap="seismic")
pl.gca().set_visible(False)
#cax = pl.axes([0.1, 0.2, 0.8, 0.6])
cax= pl.axes([0.35,0.1,0.25,.95])
pl.colorbar(cax=cax,orientation='vertical')
pl.xticks([])
pl.yticks([])
pl.savefig("colorbar.png")
pl.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment