pylab axis query and possible bug

Hi listees,

I often generate plots using the pylab interface plot() function to overlay an imshow() image. The minimal script below demonstrates a problem, which may be a bug, or may be a deliberate change introduced into mpl 0.91.1. It works fine with mpl 0.90.1 but gives a traceback with 0.91.1 - it seems not to be happy with the subplot limits. Commenting out the "note 1" line lets it run and demonstrates my real question. With scatter(), the first subplot doesn't rescale, but if line "note 2" is commented out and "note 3" is uncommented, it rescales. How do I prevent the rescaling? I prefer plot() instead of scatter() in this case because of the plot origin.

thanks,
Gary R.

···

--

from pylab import *

rcFig = {'figsize': (2,1),
          'dpi': 256,
          'subplot.hspace': 0.0,
          'subplot.wspace': 0.0,
          'subplot.bottom': 0.0,
          'subplot.left': 0.0,
          'subplot.right': 1.0,
          'subplot.top': 1.0,
          }
rc('figure', **rcFig) # note 1

subplot(121)
axis('off')
imshow(rand(20,20))
subplot(122)
axis('off')
imshow(rand(20,20))
subplot(121)
scatter([5,10],[5,10]) # note 2
#~ plot([5,10],[5,10], 'o') # note 3
show()

--

Hey Gary, thanks for the resend.

On your first question vis-a-vis subplots_adjust, it looks like the
validate limits are wrong for these params. I'm CC-ing Darren because
he has done the most work recently for rc param validation.

They currently read:

    'figure.subplot.left' : [0.125, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.right' : [0.9, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.top' : [0.9, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1,
closedmin=False, closedmax=True)],
    'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1,
closedmin=False, closedmax=True)],

and I think they should read:

    'figure.subplot.left' : [0.125, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.right' : [0.9, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.top' : [0.9, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1,
closedmin=True, closedmax=False)],
    'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1,
closedmin=True, closedmax=False)],

That is, 0 and 1 should be legal for all values except the max of the
wspace and hspace. Darren, unless I am missing something, I'll commit
these changes.

I'll look at your second question in a followup

JDH

···

On Dec 20, 2007 9:22 PM, Gary Ruben <gruben@...636...> wrote:

Hi listees,

I often generate plots using the pylab interface plot() function to
overlay an imshow() image. The minimal script below demonstrates a
problem, which may be a bug, or may be a deliberate change introduced
into mpl 0.91.1. It works fine with mpl 0.90.1 but gives a traceback
with 0.91.1 - it seems not to be happy with the subplot limits.
Commenting out the "note 1" line lets it run and demonstrates my real
question. With scatter(), the first subplot doesn't rescale, but if line
"note 2" is commented out and "note 3" is uncommented, it rescales. How
do I prevent the rescaling? I prefer plot() instead of scatter() in this
case because of the plot origin.

> Hi listees,
>
> I often generate plots using the pylab interface plot() function to
> overlay an imshow() image. The minimal script below demonstrates a
> problem, which may be a bug, or may be a deliberate change introduced
> into mpl 0.91.1. It works fine with mpl 0.90.1 but gives a traceback
> with 0.91.1 - it seems not to be happy with the subplot limits.

> Commenting out the "note 1" line lets it run and demonstrates my real
> question. With scatter(), the first subplot doesn't rescale, but if line
> "note 2" is commented out and "note 3" is uncommented, it rescales. How
> do I prevent the rescaling? I prefer plot() instead of scatter() in this
> case because of the plot origin.

You can manually turn off autoscaling on the axes instance with the
following, and both scatter and plot should then work as you want.

ax1 = subplot(121)
axis('off')
ax1.imshow(rand(20,20))
ax2 = subplot(122)
axis('off')
ax2.imshow(rand(20,20))

ax1.set_autoscale_on(False)
#ax1.scatter([5,10],[5,10]) # note 2
ax1.plot([5,10],[5,10], 'o') # note 3
show()

···

On Dec 21, 2007 11:50 AM, John Hunter <jdh2358@...287...> wrote:

On Dec 20, 2007 9:22 PM, Gary Ruben <gruben@...636...> wrote:

>

Hey Gary, thanks for the resend.

On your first question vis-a-vis subplots_adjust, it looks like the
validate limits are wrong for these params. I'm CC-ing Darren because
he has done the most work recently for rc param validation.

They currently read:

    'figure.subplot.left' : [0.125, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.right' : [0.9, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.top' : [0.9, ValidateInterval(0, 1,
closedmin=False, closedmax=False)],
    'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1,
closedmin=False, closedmax=True)],
    'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1,
closedmin=False, closedmax=True)],

and I think they should read:

    'figure.subplot.left' : [0.125, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.right' : [0.9, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.top' : [0.9, ValidateInterval(0, 1,
closedmin=True, closedmax=True)],
    'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1,
closedmin=True, closedmax=False)],
    'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1,
closedmin=True, closedmax=False)],

That is, 0 and 1 should be legal for all values except the max of the
wspace and hspace. Darren, unless I am missing something, I'll commit
these changes.

I'll look at your second question in a followup

JDH

Beautiful!
Many thanks John.

Gary R.

John Hunter wrote:
<snip>

···

You can manually turn off autoscaling on the axes instance with the
following, and both scatter and plot should then work as you want.

ax1 = subplot(121)
axis('off')
ax1.imshow(rand(20,20))
ax2 = subplot(122)
axis('off')
ax2.imshow(rand(20,20))

ax1.set_autoscale_on(False)
#ax1.scatter([5,10],[5,10]) # note 2
ax1.plot([5,10],[5,10], 'o') # note 3
show()