Skip to content

Instantly share code, notes, and snippets.

@smutch
Created July 18, 2012 06:41
Show Gist options
  • Save smutch/3134640 to your computer and use it in GitHub Desktop.
Save smutch/3134640 to your computer and use it in GitHub Desktop.
Example usage of a dummy axis.
#!/usr/bin/env python
"""Script to illustrate use of dummy axis."""
import numpy as np
import pylab as plt
# Set up the plot
# The trick is to use a twinned dummy axis to plot on and to put that on the
# bottom. The top axis is just for the ticks and is see through...
fig = plt.figure(0)
fig.clf()
axlog = fig.add_subplot(111, axis_bgcolor='none')
ax = axlog.twinx()
ax.set_zorder(-1)
ax.set_frame_on(False)
ax.set_axis_off()
# Dummy data
x = np.linspace(1, 6, 100)
y = np.linspace(1, 6, 100)
X,Y = plt.meshgrid(x, y)
Z = np.random.random_sample((100,100))
# Do the imshow
ax.imshow(Z)
# Set the scale and limits of our see through top axis with no data on it.
axlog.set_yscale('log')
axlog.set_ylim(10.**y[0], 10.**y[-1])
plt.draw()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment