ticks in Matplotlib

Hi,

I'm looking into customizing the the tick positions on an imshow plot. I found that you can do this by doing

img = imshow(data)
img.ax.xaxis.set_ticks([100.,200.])

The problem with this method is that it moves the tick positions on the bottom and top x axis. What if I wanted to do have the top axes show ticks at slightly different positions than the bottom one? Any ideas or suggestions would be greatly appreciated

-Eli

You cannot set different tick positions for bottom and top x-axis in
the same axes.
What you can do is to make another axes at the same location and use
it to draw ticks at top.
Take a look at

http://matplotlib.sourceforge.net/examples/api/two_scales.html

But it may not be an ideal solution for you as this enforces
adjustable="datalim".

You may try to use my custom axes class.

http://dl.getdropbox.com/u/178748/mpl/parasite_axes2.py

import matplotlib.pyplot as plt
import numpy as np

from parasite_axes2 import SubplotHost

fig = plt.gcf()
ax = SubplotHost(fig, 1, 1, 1)
fig.add_subplot(ax)
Z = np.arange(100).reshape(10,10)
im = ax.imshow(Z)

ax2 = ax.twin()

ax2.set_xticks([0, 3, 6, 9])
ax2.set_yticks([1,3,5,7,9])

plt.draw()
plt.show()

Note that it enforces that ax2 has a same viewlim as the original
axes. You cannot manually change it.

-JJ

ยทยทยท

On Sun, Feb 1, 2009 at 12:41 PM, Eli Bressert <bressert@...2475...> wrote:

Hi,

I'm looking into customizing the the tick positions on an imshow plot. I
found that you can do this by doing

img = imshow(data)
img.ax.xaxis.set_ticks([100.,200.])

The problem with this method is that it moves the tick positions on the
bottom and top x axis. What if I wanted to do have the top axes show
ticks at slightly different positions than the bottom one? Any ideas or
suggestions would be greatly appreciated

-Eli

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options