Joseph Smidt wrote:
> Okay, I am another gnuplot user trying to migrate over to matplotlib.
> I like what I see, but there are a couple things that are very easy to
> do in Gnuplot that I can't figure out how to do with matplotlib.
> 
> I have a file with 3 columns of data called data.txt that looks like:
> 
> 0.0000      1.0000     1.0
> 0.0634      1.0655      1.1353
> 0.1269      1.1353      1.28899916094
> 0.1903      1.2097      1.46345358199
> 0.2538      1.2889     1.6615188369
> 0.3173      1.3734     1.88639043926
> ...
> 
> I can plot this data, 2 versus 1 and 3 versus 1, very easily on the
> same plot, with a legend, with log y values, and only for the xrange
> between 2 and 3 with gnuplot:
> 
> set log y
> set xrange[2:3]
> plot 'data.txt' u 1:2 w l t 'apples', 'data.txt' u 1:3 w l t 'oranges'
> 
> Now, how do I do that same thing with matplotlob?  Ie:
> 
> 1. Both graphs overlayed on the same plot.
> 2. Semilogy. (log y values),
> 3. Only ploy for x in the range 2-3.
> 4. Legend for the two graphs on same plot.

Something like this:

import numpy as np
import matplotlib.pyplot as plt

x, apples, oranges = np.loadtxt('data.txt', unpack=True)
plt.semilogy(x, apples, label='apples')
plt.semilogy(x, oranges, label='oranges')
plt.legend()
plt.gca().set_xlim(2, 3)
plt.show()

There are many possible variations and styles.  The basic point is to 
separate reading in the data from plotting it.  Plotfile won't do what 
you want because it is designed to make separate subplots instead of 
plotting multiple lines on a single axes.  Maybe doing the latter would 
be at least as useful, if not more, and could be enabled as an option 
with one more kwarg.

Eric

> 
> I have spent time looking through the documentation but I can't find
> anyway to do this is any straightforward way.  plotfile() looks
> promising, but I can't seem to make it do the above.  Thanks in
> advance.
> 
>                              Joseph Smidt
> 


------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to