[Tutor] changing coordinate

Evert Rol evert.rol at gmail.com
Wed Jan 11 12:32:52 CET 2012


  Hi Sue,

> I am trying to define a new coordinate for My plot.
> 
> I have a plot x axis is Concentration, Y axis, depth or Z.
> 
> Z= -1000 um.
> and I would like to see the the trend and plot of concentration up to
> -300 um and see how the plot changed according to the depth. So, my
> main question is about how to change the coordinate based on 0 to
> -300.

I'm not exactly sure what you want, but it sounds you just want to change the yaxis scaling. 
If that's the case, use pylot.axis or pyplot.ylim (see the matplotlib documentation if necessary).

If you're just trying to subtract 300 from your z values, I think this part of your code:

> z == z + h_s

has the problem: it's a comparison, not an assignment, because of the double '==' (presumably a simple but unfortunate typo).

If it's something else, you might need to clarify your description or give an example.

Cheers,

  Evert


> 
> This is the relevant description:
> 
> # coding: utf-8
> from pylab import *
> import numpy
> import matplotlib.pyplot as pyplot
> import matplotlib.mlab as mlab
> 
> #t=3600
> N = 100
> dz = 1.0
> h_s=-300
> 
> 
> with open("ourtest_out.list", "r") as f:
>   z = numpy.array([float(v) for v in f.readline().split()[1:]])
> 
> z == z + h_s
> a = numpy.loadtxt("ourtest_out.list", skiprows=3)
> t=a[:,0]
> 
> nu = a[0:,1:N+1]
> Conc = a[0:, N+1:]
> 
> lw = 2.0 #linewidth
> dpi = 96
> figure(figsize=(12,6),dpi=dpi)
> 
> pyplot.plot(Conc[1], z,'r-')
> pyplot.xlabel('$Conc, mmol C m^3$')
> pyplot.ylabel('$Hsml, micrometer$')
> pyplot.grid(True)
> 
> legend()
> savefig('Conc.png')
> show()
> 
> 
> lw = 2.0 #linewidth
> dpi = 96
> figure(figsize=(12,6),dpi=dpi)
> semilogx(Conc[1], z,'r-')
> pyplot.xlabel('$Conc, mmol C m^3$')
> pyplot.ylabel('$Hsml, micrometer$')
> pyplot.grid(True)
> 
> legend()
> savefig('semiConc.png')
> show()
> 
> 
> lw = 2.0 #linewidth
> dpi = 96
> figure(figsize=(12,6),dpi=dpi)
> 
> semilogx(nu[1], z,'r-')
> pyplot.xlabel('$nu, m^2/s^{-1}$')
> pyplot.ylabel('$Hsml, micrometer$')
> pyplot.grid(True)
> 
> legend()
> savefig('nu.png')
> show()
> --------------
> I do appreciate any help and advice.
> 
> Thanks,Sue
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list