Skip to content
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

fixing colour bar example #17

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
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
13 changes: 3 additions & 10 deletions _episodes/03-matplotlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,14 @@ which is the default for plotting matrix-type data (because this is where `[0:0]
We can also add a colour bar to help describe the figure, with a little more code:

~~~
import mpl_toolkits

matplotlib.pyplot.figure()
fig = matplotlib.pyplot.figure(figsize=(12.0,4.0))
ax = matplotlib.pyplot.gca()
im = ax.imshow(globaldata["hs_avg"][0], extent=[0,360,-90,90], origin='lower')

divider = mpl_toolkits.axes_grid1.make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)

matplotlib.pyplot.colorbar(im, cax=cax)
cbar = fig.colorbar(im, ax=ax, location="right", pad=0.02)
matplotlib.pyplot.show()
~~~
{: .language-python}

Here, we don't need to use the `mpl_toolkits` library, but it's useful to help format the colourbar.

![Global surface waveheight with a colourbar](../fig/global_surfaceu-colourbar.svg)


Expand Down