|
From: Damon M. <dam...@gm...> - 2012-10-02 19:49:25
|
On Tue, Oct 2, 2012 at 8:33 PM, Michael Aye <kmi...@gm...> wrote: >>>>>>>>> >>>>>>>> How nice of you to ask! ;) >>>>>>>> Indeed: I had the case that image arrays inside an ImageGrid where >>>>>>>> shown with some white overhead area around, e.g. for an image of 100 >>>>>>>> pixels on the x-axis, the imshow resulted in an x-axis that went from >>>>>>>> -10 to 110. I was looking for a simple way to suppress that behavior >>>>>>>> and let imshow instead use the exact image extent. I believe that the >>>>>>>> plot command has such a flag, hasn't it? (I.e. to use the exact xdata >>>>>>>> range and not try to beautify the plot? >>>>>>>> >>>>>>>> Michael >>>>>>> >>>>>>> Is the 'extent' keyword what you're looking for? >>>>>>> >>>>>> >>>>>> No, because it needs detail. I was looking for a boolean switch that >>>>>> basically says: Respect the data, not beauty. >>>>> >>>>> I don't understand what you mean by 'beauty'. If your image is 100 >>>>> pixels wide and 50 pixels tall, what is it about extent=[0,100,0,50] >>>>> that doesn't do what you want? >>>>> >>>> As I wrote, that's not what is happening. I get extent=[-10,110,0,50]. >>>> >>>> >>> >>> The following script works for me: >>> >>> import numpy as np >>> import matplotlib.pyplot as plt >>> >>> image = np.random.random((100,50)) >>> >>> fig = plt.figure() >>> ax = fig.add_subplot(1, 1, 1) >>> ax.imshow(image, extent=[0,100,0,50]) >>> plt.show() >>> >>> >> >> I think the problem is that Michael is using ImageGrid, and apparently >> it is not using the tight autoscaling that imshow normally uses by default. > > I might have confused where I had the problem as I was trying out many > a'things yesterday, so today I only can reproduce it with subplots. Can > I activate tight autoscaling somehow? tight_layout only influences the > axes towards each-other not the imshows itself. > > >> >> Eric >> >> ------------------------------------------------------------------------------ >> Don't let slow site performance ruin your business. Deploy New Relic APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev > > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users I think you may have encountered a bug, as Ben pointed out. Here's a workaround: import matplotlib matplotlib.use('macosx') import matplotlib.pyplot as plt from numpy import arange, array arr = arange(10000).reshape(100,100) l = [arr,arr,arr,arr] narr = array(l) axes = [] fig = plt.figure() for i in range(4): axes.append(fig.add_subplot(2, 2, i)) for ax, im in zip(axes, narr): ax.imshow(im, extent=[0,100,0,100]) plt.show() -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom |