Text of discourse.matplotlib.org › t › axes-scaling › 16604 as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Axes Scaling - matplotlib-users - Matplotlib

Axes Scaling Community matplotlib-users Francois_Lemery February 17, 2012, 7:07pm 1 Hi Python World! I currently have a 2D array: A[i][j] which I can plot very nicely using the contourf function. However, in this plot, the axes span from (0, i) and (0, j). I would like to multiply each axes by a scaling constant- thereby turning the array element values into physical quantities (distance and time for example). Could anyone help me with this?

I've looked around, but so far the only solution I have found is to create a new set of arrays with these scaling factors included. I can do this, but I feel as though it would be a waste. ··· -- Thanks! François Alexa February 17, 2012, 7:26pm 2 Hi François, Why would it be a waste to multiply the values in an array by the scaling factors? Can you provide an example of your code so everybody can get a better idea of what you’re doing now?

Thanks, Alexa ··· On Fri, Feb 17, 2012 at 9:07 AM, Francois Lemery <francois.lemery@…1896…> wrote: Hi Python World! I currently have a 2D array: A[i][j] which I can plot very nicely using the contourf function. However, in this plot, the axes span from (0, i) and (0, j). I would like to multiply each axes by a scaling constant- thereby turning the array element values into physical quantities (distance and time for example).

Could anyone help me with this? I’ve looked around, but so far the only solution I have found is to create a new set of arrays with these scaling factors included. I can do this, but I feel as though it would be a waste. – Thanks! François Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users Francois_Lemery February 17, 2012, 7:43pm 3 Hi, Sorry for not giving sufficient detail.

I open an HDF5 file and then read some EArray into a regular array: a = f.root MySource = a.myLineSource[:,:,1] # the dimensions of my source are (x, t) = (50, 15000) 50 corresponds to 50 gridpoints where I have recorded an electric field. and 15,000 corresponds to the number of timesteps I have run in my simulation. figure() A1=contourf(MySource) # When I do this, it gives me a beautiful plot. However the x axis spans (0, 50) when I would like it to go from (0, 50)*DX.

Similarly, in time, my plot spans (0, 15,000) when I would like it to range from (0, 15000)*DT Where DX and DT are some real numbers (e.g. a micron, and a femtosecond.) I would suspect there to be some 'scaling' feature already available in python for just this kind of thing. That is why I argued that introducing new arrays to incorporate the adjusted/properly scaled values would be a waste. Thanks again! ··· On Fri, Feb 17, 2012 at 1:26 PM, Alexa Villaume < [email protected] ...> wrote: Hi François, Why would it be a waste to multiply the values in an array by the scaling factors?

Can you provide an example of your code so everybody can get a better idea of what you're doing now? Thanks, Alexa On Fri, Feb 17, 2012 at 9:07 AM, Francois Lemery < [email protected] .....> > wrote: Hi Python World! I currently have a 2D array: A[i][j] which I can plot very nicely using the contourf function. However, in this plot, the axes span from (0, i) and (0, j). I would like to multiply each axes by a scaling constant- thereby turning the array element values into physical quantities (distance and time for example).

Could anyone help me with this? I've looked around, but so far the only solution I have found is to create a new set of arrays with these scaling factors included. I can do this, but I feel as though it would be a waste. -- Thanks! François ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Matplotlib-users mailing list [email protected] matplotlib-users List Signup and Options -- Thanks, François Jerzy_Karczmarczuk February 17, 2012, 7:46pm 4 Francois Lemery : Hi Python World!

I currently have a 2D array: A[i][j] which I can plot very nicely using the contourf function. However, in this plot, the axes span from (0, i) and (0, j). I would like to multiply each axes by a scaling constant- thereby turning the array element values into physical quantities (distance and time for example). Could anyone help me with this? I've looked around, but so far the only solution I have found is to create a new set of arrays with these scaling factors included.

I can do this, but I feel as though it would be a waste. You want just to change your labelling? No problemo, Baby. xmin,xmax = ........ ymin,ymax = ........ ... tbl=... ic=contourf(tbl, extent=(xmin,xmax,ymin,ymax)) axis([xmin,xmax,ymin,ymax]) show() ··· ==== Bon courage. Now, if you want to change your *values*, as Alexa understood, then be more precise, please. Jerzy Karczmarczuk Ray_Osborn February 18, 2012, 1:55am 5 I am embedding a matplotlib canvas in a Pyside GUI and wanted to attach a slider to adjust the color scale of a 2D plot made using NonUnitformImage.

I am connecting the slider value to im.set_clim([vmin,vmax]). I have got my axis sliders to work, but the intensity slider only adjusts the colorbar without touching the image itself. Is there some trick to making this work with NonUniformImage? My plotting routine has the following code: ax = plt.gca() im = NonUniformImage(ax, extent=extent, origin=None, **opts) im.set_data(x,y,z) ax.images.append(im) self.imgplot = im plt.colorbar(im) while the Pyside slot has: zhi = self.zmin + (self.ztab.maxslider.value() * range / 100) im = self.imgplot im.set_clim([zlo,zhi]) The slider dynamically adjusts the colorbar beautifully, but leaves the color plot untouched.

Any suggestions welcome. Thanks in advance, Ray ··· -- Ray Osborn Materials Science Division Argonne National Laboratory Argonne, IL 60439, USA Phone: +1 (630) 252-9011 Email: [email protected] ... Benjamin_Root February 18, 2012, 3:05am 6 Without a more complete example, it is hard to say. Can you make a small stand-alone example that we can try out? Ben Root ··· On Friday, February 17, 2012, Ray Osborn wrote: I am embedding a matplotlib canvas in a Pyside GUI and wanted to attach a slider to adjust the color scale of a 2D plot made using NonUnitformImage.

I am connecting the slider value to im.set_clim([vmin,vmax]). I have got my axis sliders to work, but the intensity slider only adjusts the colorbar without touching the image itself. Is there some trick to making this work with NonUniformImage? My plotting routine has the following code: ax = plt.gca() im = NonUniformImage(ax, extent=extent, origin=None, **opts) im.set_data(x,y,z) ax.images.append(im) self.imgplot = im plt.colorbar(im) while the Pyside slot has: zhi = self.zmin + (self.ztab.maxslider.value() * range / 100) im = self.imgplot im.set_clim([zlo,zhi]) The slider dynamically adjusts the colorbar beautifully, but leaves the color plot untouched.

Any suggestions welcome. Thanks in advance, Ray Ray_Osborn February 18, 2012, 4:02am 7 OK - it turns out I can reproduce it in a simple ipython session using ipython --pylab=qt. I set up an image plot as follows: import numpy as np import matplotlib.pyplot as plt from matplotlib.image import NonUniformImage x=y=np.linspace(0,2*np.pi,101) X,Y=np.meshgrid(x,y) z=sin(X)*sin(Y) ax=plt.gca() extent = (x[0],x[-1],y[0],y[-1]) im = NonUniformImage(ax, extent=extent, origin=None) im.set_data(x,y,z) ax.images.append(im) ax.set_xlim(x[0],x[-1]) ax.set_ylim(y[0],y[-1]) plt.colorbar(im) plt.gcf().canvas.draw() After that, I try to change th

The rest of this page is on the live site.