Creating an oceanographic profile with matplotlib

Hi all,

I am trying to plot an oceanographic profile using some ocean data I have. The thing is that in oceanograhy it is common to display graphs where the independent variable (x) is depth, and some other data (i.e salinity or temperature) is plotted against it. The graph is supposed to look like this for example:

                                                     y
···
           _______________________________
          >                                                    *

          >                                                   *
          >                                          *  * *
          >                                        *
          >                                      *

          >                                     *
     x   |                                 *
          >                               *
          >                            *
          >                         *

          >                        *
          >                      *
          >                    *      
          >                  *
          >                  *
          >                  *

so far I have managed to plot the graph with invert x axis, but I don’t know how to change the default graph option of intercept of axes in the bottom left corner.
So I hope I made my question clear: how can I plot a graph with intecept of axes in the upper left corner ?

Thanks,
Oz Nahum,
Department of Oceanography,
Hebrew University, Jerusalem

Oz Nahum wrote:

Hi all,

I am trying to plot an oceanographic profile using some ocean data I have. The thing is that in oceanograhy it is common to display graphs where the independent variable (x) is depth, and some other data (i.e salinity or temperature) is plotted against it. The graph is supposed to look like this for example:
                                                                                                     y
               _______________________________
              > *
              > *
              > * * *
              > *
              > *
              > *
         x | *
              > *
              > *
              > *
              > *
              > *
              > * > *
              > *

so far I have managed to plot the graph with invert x axis, but I don't know how to change the default graph option of intercept of axes in the bottom left corner.
So I hope I made my question clear: how can I plot a graph with intecept of axes in the upper left corner ?

Try this:

import numpy as np
import matplotlib.pyplot as plt
salinity = np.random.random(50)
depth = np.linspace(1, 500)
plt.plot(salinity, depth)
ax = plt.gca()
ax.set_ylim(500, 0)

Things to note:
1) Matplotlib doesn't care about dependent or independent variables. With plot(x,y), one variable gets mapped to the x-axis, one gets mapped to the y-axis.
2)ax.set_ylim says that the call is (min,max), but what it really means is (lower,upper). This could probably be clearer in the docs.

HTH,

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

or more appropriately you might need this

from pylab import *

setp(gca(), ‘xticklabels’, )
subplot(111)
ax=twiny()
y = [1, 2, 3, 4]
x = [5, 4, 2, 2]
plot(x, y, ‘ro-’)
ylim(5,0)
xlim(1,6)
ax.xaxis.tick_top()
xlabel(‘Y’)
ylabel(‘X’)
show()

···

On Fri, Jun 13, 2008 at 10:24 AM, Oz Nahum <nahumoz@…1972…> wrote:

Hi all,

I am trying to plot an oceanographic profile using some ocean data I have. The thing is that in oceanograhy it is common to display graphs where the independent variable (x) is depth, and some other data (i.e salinity or temperature) is plotted against it. The graph is supposed to look like this for example:

                                                     y
           _______________________________
          >                                                    *



          >                                                   *
          >                                          *  * *
          >                                        *
          >                                      *



          >                                     *
     x   |                                 *
          >                               *
          >                            *
          >                         *



          >                        *
          >                      *
          >                    *      
          >                  *
          >                  *
          >                  *

so far I have managed to plot the graph with invert x axis, but I don’t know how to change the default graph option of intercept of axes in the bottom left corner.
So I hope I made my question clear: how can I plot a graph with intecept of axes in the upper left corner ?

Thanks,
Oz Nahum,
Department of Oceanography,
Hebrew University, Jerusalem


Check out the new SourceForge.net Marketplace.

It’s the best place to buy or sell services for

just about anything Open Source.

http://sourceforge.net/services/buy/index.php


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thank you very much !
That did it for me.

If I get it right ax=twiny or ax=gca()
defines the plot type ?

···

On Fri, Jun 13, 2008 at 9:35 PM, Abhinav Verma <abhinav1205@…287…> wrote:

or more appropriately you might need this

from pylab import *

setp(gca(), ‘xticklabels’, )

subplot(111)
ax=twiny()

y = [1, 2, 3, 4]
x = [5, 4, 2, 2]

plot(x, y, ‘ro-’)

ylim(5,0)

xlim(1,6)
ax.xaxis.tick_top()

xlabel(‘Y’)
ylabel(‘X’)
show()

On Fri, Jun 13, 2008 at 10:24 AM, Oz Nahum <nahumoz@…287…> wrote:

Hi all,

I am trying to plot an oceanographic profile using some ocean data I have. The thing is that in oceanograhy it is common to display graphs where the independent variable (x) is depth, and some other data (i.e salinity or temperature) is plotted against it. The graph is supposed to look like this for example:

                                                     y
           _______________________________
          >                                                    *




          >                                                   *
          >                                          *  * *
          >                                        *
          >                                      *




          >                                     *
     x   |                                 *
          >                               *
          >                            *
          >                         *




          >                        *
          >                      *
          >                    *      
          >                  *
          >                  *
          >                  *

so far I have managed to plot the graph with invert x axis, but I don’t know how to change the default graph option of intercept of axes in the bottom left corner.
So I hope I made my question clear: how can I plot a graph with intecept of axes in the upper left corner ?

Thanks,
Oz Nahum,
Department of Oceanography,
Hebrew University, Jerusalem


Check out the new SourceForge.net Marketplace.

It’s the best place to buy or sell services for

just about anything Open Source.

http://sourceforge.net/services/buy/index.php


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users