Created
July 18, 2012 06:41
-
-
Save smutch/3134640 to your computer and use it in GitHub Desktop.
Example usage of a dummy axis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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