imshow axis labels

Hi,
    I'm using imshow to make an image of a 2-d matrix. I use set_xticklabels to adjust the x-axis labels. The problem is that when I then zoom in on the plot, the axis labels are not adjusted appropriately. Does anyone suggestions on how I can fix this?

Thanks
Jeremy

What are you setting the x ticklabels to? If you want to control how the numbers are displayed, you can create a custom formatter (which is basically a function to convert a floating-point number to a string). If you want to control the number of ticks across the axis, you can make a custom ticker.

If you can describe what your end goal is, I'm happy to describe the above options in more detail.

Cheers,
Mike

Jeremy Lewi wrote:

···

Hi,
    I'm using imshow to make an image of a 2-d matrix. I use set_xticklabels to adjust the x-axis labels. The problem is that when I then zoom in on the plot, the axis labels are not adjusted appropriately. Does anyone suggestions on how I can fix this?

Thanks
Jeremy

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

I want to let matplotlib control where the tick marks go, but I want to scale the value of the tick labels. For example,
if my matrix has a 100 columns the tick marks might be [0,25,50,100]. I want to scale these tick labels by some value say .01 so that the corresponding tick labels would be [0,.25,.5,1].

Now say I zoom in on the image so that the xaxis limits are (0,50). Lets suppose the tick marks are now [0,10,20,30,40,50]
Then in this case the tick labels should be
[0,.1,.2,.3,.4,.5]

So how do I go about creating a custom formatter?

Thanks
Jeremy

Michael Droettboom wrote:

···

What are you setting the x ticklabels to? If you want to control how the numbers are displayed, you can create a custom formatter (which is basically a function to convert a floating-point number to a string). If you want to control the number of ticks across the axis, you can make a custom ticker.

If you can describe what your end goal is, I'm happy to describe the above options in more detail.

Cheers,
Mike

Jeremy Lewi wrote:
  

Hi,
    I'm using imshow to make an image of a 2-d matrix. I use set_xticklabels to adjust the x-axis labels. The problem is that when I then zoom in on the plot, the axis labels are not adjusted appropriately. Does anyone suggestions on how I can fix this?

Thanks
Jeremy

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  

You may just want to start with the "custom_ticker1.py" example here:

http://matplotlib.sourceforge.net/examples/pylab_examples/custom_ticker1.html

The meat of it is just to provide a function that converts the incoming values (in your case pixel positions) into whatever you want to be displayed.

Cheers,
Mike

Jeremy Lewi wrote:

···

I want to let matplotlib control where the tick marks go, but I want to scale the value of the tick labels. For example,
if my matrix has a 100 columns the tick marks might be [0,25,50,100]. I want to scale these tick labels by some value say .01 so that the corresponding tick labels would be [0,.25,.5,1].

Now say I zoom in on the image so that the xaxis limits are (0,50). Lets suppose the tick marks are now [0,10,20,30,40,50]
Then in this case the tick labels should be
[0,.1,.2,.3,.4,.5]

So how do I go about creating a custom formatter?

Thanks
Jeremy

Michael Droettboom wrote:

What are you setting the x ticklabels to? If you want to control how the numbers are displayed, you can create a custom formatter (which is basically a function to convert a floating-point number to a string). If you want to control the number of ticks across the axis, you can make a custom ticker.

If you can describe what your end goal is, I'm happy to describe the above options in more detail.

Cheers,
Mike

Jeremy Lewi wrote:

Hi,
    I'm using imshow to make an image of a 2-d matrix. I use set_xticklabels to adjust the x-axis labels. The problem is that when I then zoom in on the plot, the axis labels are not adjusted appropriately. Does anyone suggestions on how I can fix this?

Thanks
Jeremy

------------------------------------------------------------------------------

Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
      
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA