Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plot only the first rows

1,214 views
Skip to first unread message

Sebastian Schubert

unread,
Dec 23, 2005, 2:57:30 PM12/23/05
to
Hi,

I want to plot only the first rows of my data file. I can use 'using' to
select which columns to plot but how can select which rows?
My data file looks eg
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7

and I want plot it as if it were

1 3
2 4
3 5

taking only some columns and rows.

TIA

Sebastian

Kamaraju Kusumanchi

unread,
Dec 23, 2005, 10:33:08 PM12/23/05
to

I wanted to do exactly the same thing before. I dont think gnuplot is
capable of doing that. The work around I finally settled upon is to load
the data into a matrix say A and then plot A(1,:) vs A(2,:). If you are
using linux, you can use octave (which in turn uses gnuplot for
graphics) for doing this. If you have money matlab is also an option.

hth
raju

--
Kamaraju S Kusumanchi
http://www.people.cornell.edu/pages/kk288/
http://malayamaarutham.blogspot.com/

Ethan Merritt

unread,
Dec 24, 2005, 1:54:41 AM12/24/05
to
In article <43ac56a3$0$9647$9b4e...@newsread2.arcor-online.net>,

Sebastian Schubert <sebastian...@gmx.de> wrote:
>
>I want to plot only the first rows of my data file.

plot '< head -3 foo'


>I can use 'using' to
>select which columns to plot but how can select which rows?
>My data file looks eg
>1 2 3
>2 3 4
>3 4 5
>4 5 6
>5 6 7
>
>and I want plot it as if it were
>
>1 3
>2 4
>3 5
>
>taking only some columns and rows.
>
>TIA
>
>Sebastian


--
Ethan A Merritt

Hans-Bernhard Broeker

unread,
Dec 25, 2005, 8:51:11 AM12/25/05
to
Sebastian Schubert <sebastian...@gmx.de> wrote:
> I want to plot only the first rows of my data file. I can use 'using' to
> select which columns to plot but how can select which rows?

help every

--
Hans-Bernhard Broeker (bro...@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Sebastian Schubert

unread,
Dec 26, 2005, 2:49:34 PM12/26/05
to
Ethan Merritt wrote:

> In article <43ac56a3$0$9647$9b4e...@newsread2.arcor-online.net>,
> Sebastian Schubert <sebastian...@gmx.de> wrote:
>>
>>I want to plot only the first rows of my data file.
>
> plot '< head -3 foo'
>

Nice, do you know a possiblity to select rows 10..134 for example? Couldn't
find a solution.

Thx
Sebastian

Sebastian Schubert

unread,
Dec 26, 2005, 2:39:11 PM12/26/05
to
Kamaraju Kusumanchi wrote:

> Sebastian Schubert wrote:
>> Hi,
>>
>> I want to plot only the first rows of my data file. I can use 'using' to
>> select which columns to plot but how can select which rows?
>> My data file looks eg
>> 1 2 3
>> 2 3 4
>> 3 4 5
>> 4 5 6
>> 5 6 7
>>
>> and I want plot it as if it were
>>
>> 1 3
>> 2 4
>> 3 5
>>
>> taking only some columns and rows.
>
> I wanted to do exactly the same thing before. I dont think gnuplot is
> capable of doing that. The work around I finally settled upon is to load
> the data into a matrix say A and then plot A(1,:) vs A(2,:). If you are
> using linux, you can use octave (which in turn uses gnuplot for
> graphics) for doing this. If you have money matlab is also an option.

Thx, this is a nice idea as I know octave a bit. The problem is that I don't
like octave's way of using gnuplot. I like to have full control (at least I
have to set terminal to epslatex) and everytime I use gset it wants me to
use __gnuplot_set__. So I get the feeling that I rather should use gnuplot
for plotting.

Sebastian

Sebastian Schubert

unread,
Dec 26, 2005, 2:52:51 PM12/26/05
to
Hans-Bernhard Broeker wrote:

> Sebastian Schubert <sebastian...@gmx.de> wrote:
>> I want to plot only the first rows of my data file. I can use 'using' to
>> select which columns to plot but how can select which rows?
>
> help every
>

Thx for advice. The probleme is that I actually need to calculate the values
I have to plot by combining several columns (yes, I haven't mentioned
that). It seems to me that I can't use using and every at the same time.

Thx
Sebastian

Peter Weilbacher

unread,
Dec 26, 2005, 4:10:05 PM12/26/05
to

plot '< head -134 foo | tail +10'

Grüße von
Peter.

Sebastian Schubert

unread,
Dec 26, 2005, 8:31:40 PM12/26/05
to
Peter Weilbacher wrote:

Mmmh... I should have seen this myself...

Thx
Sebastian

Surinder Singh

unread,
Dec 27, 2005, 10:45:08 AM12/27/05
to

"Sebastian Schubert" <sebastian...@gmx.de> wrote in message
news:43b04a06$0$3795$9b4e...@newsread2.arcor-online.net...

> Thx for advice. The probleme is that I actually need to calculate the
> values
> I have to plot by combining several columns (yes, I haven't mentioned
> that). It seems to me that I can't use using and every at the same time.

You could use Gnuplot to select the rows it plots by using any formula that
combines many columns.


plot 1:($2*$3 > 5 ? $6 : 1/0) ...

will check if the product of column 2 and 3 is greater than 5. If so, it
will column 6 on y axis; if not, it will make a null value of 1/0 and
therfore not anything.

HTH.

s


Hans-Bernhard Broeker

unread,
Dec 30, 2005, 3:14:06 PM12/30/05
to
Sebastian Schubert <sebastian...@gmx.de> wrote:

> The probleme is that I actually need to calculate the values I have
> to plot by combining several columns (yes, I haven't mentioned
> that). It seems to me that I can't use using and every at the same
> time.

And what made you think that?

gnuplot is a somewhat complex program. You may have to actually read
the documentation to use it.

Lutz Maibaum

unread,
Jan 19, 2006, 5:38:53 PM1/19/06
to
Peter Weilbacher <news...@weilbacher.org> wrote:
>> Nice, do you know a possiblity to select rows 10..134 for example? Couldn't
>> find a solution.
>
> plot '< head -134 foo | tail +10'

Just for completeness, I think that something like

plot "foo" using 1:($0 >= 9 && $0 <= 133 ? $2 : 1/0)

should also work.

Lutz

0 new messages