Arnd Baecker | 1 Sep 2005 19:34
Picon

Re: Plotting a matrix in some region

Hi John,

thank you very much for your quick reply!
It seems things are slightly more complicated, though...

On Thu, 1 Sep 2005, John Hunter wrote:

> On 9/1/05, Arnd Baecker <arnd.baecker@...> wrote:
>
>   > today I urgently needed to plot a matrix in a given
>   > region of a plot. It seems that imshow does not
>   > support this (at least I could not find how)
>   > and I don't understand the internals well
>   > enough to add such a feature.
>   > As work-around I have set up the quick hack listed
>   > at the end of this mail.
>   > It is not really complicated, but
>   > maybe it is useful to someone else.
>
> If I'm understanding you correctly, you want to set the "extent"
> argument of imshow

Well, I thought so too, but I also need `axis("equal")`
and depending on the order of setting the
axis intervals (`axis([-0.35,2.1,-0.2,1.25])`)
before or after this, one obtains completely different results.

Below is an example, where this is illustrated,
by changing the code at the places marked by ===>.

So the example I posted was stripped down too strongly
(and your solution does work for that case!).

Best,

Arnd

P.S.: I ran my test with yesterdays CVS.

###################
from pylab import *

# ===> uncommenting this gives a different result:
#ax=subplot(111,autoscale_on=False)

# ===> changing the order of these two gives different results:
axis("equal")
axis([-0.35,2.1,-0.2,1.25])
    # (note that -0.2 and 1.25 are not respected)

arr=reshape(arange(25),(5,5))

# ===> commenting this one out, when autoscale_on=False
#      gives the expected result
imshow(arr, extent=[0.5,1.0,0.2,0.8])

# plot a circle to see if the aspect ratio is correct:
phi=arange(0.0,2.0*pi,0.01)
x=0.5*cos(phi)+0.5
y=0.5*sin(phi)+0.5

plot(x,y,lw="8")

show()

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf

Gmane