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

plotting row data from a datafile?

8,512 views
Skip to first unread message

Anthony Gray

unread,
Mar 9, 2005, 10:01:21 AM3/9/05
to
Apologies in advance for what must be an easy question.

Is there a simple way to plot a datafile which stores data in rows
rather than in columns?

I am sure there is, but I am just learning gnuplot and I can't figure
out an answer from the documentation.

Many thanks!

-- Tony

Theo Hopman

unread,
Mar 9, 2005, 11:05:16 AM3/9/05
to

I'm surprised I didn't find this in the FAQ. The answer is (contrary to
your expectations) no. You'll have to rearrange your data. If you're on
a platform that supports piping (i.e, virtually everything except
Windows), you can do it on the fly. Assuming white-space-separated
data, something like the following should work:

plot "< awk '{for(i=1;i<=NF;i++) print $i}' datafile"

THeo

Anthony Gray

unread,
Mar 9, 2005, 12:24:54 PM3/9/05
to
Hi Theo...

Thanks for your reply. I am a bit surprised that gnuplot lacks this
capability!

Reformatting the data, as you suggest, will not be a problem.

> I'm surprised I didn't find this in the FAQ.

Is there a mechanism to have it added somehow? It seems like a natural
question.

Thanks again for your help.

Best,

-- Tony

In article <1110384316.7...@l41g2000cwc.googlegroups.com>,

Theo Hopman

unread,
Mar 10, 2005, 9:33:31 AM3/10/05
to

Anthony Gray wrote:
> Thanks for your reply. I am a bit surprised that gnuplot lacks this
> capability!
>
> Reformatting the data, as you suggest, will not be a problem.

gnuplot is no less immune to creeping featuritis than any other
program, but the underlying philosophy is supposed to be "do one thing,
and do it well". Since text reformatting can be done so well by
external tools, why add it to gnuplot?

That said, it probably would be a relatively simple matter to make the
"record separator" and "field separator" (using awk terminolgy)
completely user-definable, along with a "block separator" and "index
separator", perhaps even in terms of regular expressions. (One can
already define the "field separator" in a limited way using `set
datafile separator`.) As I see it, one could then define the record
separator to be (e.g.) whitespace instead of a newline, allowing a
single row of data to be plotted (although only against record number).

> > I'm surprised I didn't find this in the FAQ.
>
> Is there a mechanism to have it added somehow? It seems like a
natural
> question.

Good question, to which I don't know the answer.

THeo

mkors...@gmail.com

unread,
Sep 20, 2018, 1:40:26 AM9/20/18
to
On Wednesday, March 9, 2005 at 4:01:21 PM UTC+1, Anthony Gray wrote:
> Is there a simple way to plot a datafile which stores data in rows
> rather than in columns?
>
> I am sure there is, but I am just learning gnuplot and I can't figure
> out an answer from the documentation.

There is a simple way to do this using the matrix directive. Replace n1 with the desired row number:

plot 'data' matrix every :::n1::n1
0 new messages