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

How to draw points along a line at every 5 or 10 data point?

5,060 views
Skip to first unread message

K. Lee

unread,
Feb 2, 2010, 4:25:33 PM2/2/10
to
Hello all,

Since I have many points, it looks ugly if I draw my data set with
'linespoints.' I can go with just 'lines,' but I'd like to put
points(markers) as well at every 5 or 10 data point. I hope someone
could help me do this in gnuplot. Thank you.

Hans-Bernhard Bröker

unread,
Feb 2, 2010, 4:53:49 PM2/2/10
to

Plot the file twice, once "with lines", then again "every 5 with points".

K. Lee

unread,
Feb 3, 2010, 6:06:30 AM2/3/10
to

Thank you for your advice. In that case, I'm afraid my legend would be
slightly incorrect, since it can have only either "line" or "point";
however, my line will have both "line" and "point" in a plot after
drawing twice.

Stefan Nowy

unread,
Feb 4, 2010, 5:16:54 AM2/4/10
to
Hi,

> Thank you for your advice. In that case, I'm afraid my legend would be
> slightly incorrect, since it can have only either "line" or "point";
> however, my line will have both "line" and "point" in a plot after
> drawing twice.

plot "datafile" w l t 'my data', "" every 5 w p t ''

should help you with the key

Stefan

K. Lee

unread,
Feb 4, 2010, 9:47:28 AM2/4/10
to

Thank you, but with your suggestion, I end up with a key showing only a
line segment. Since now I can draw a line along with points at every 5
point, I'd like to have a key showing both line & point. I'm not sure
how can I do that.

Karsten Hentsch

unread,
Feb 4, 2010, 10:42:52 AM2/4/10
to

what about:
plot
datafile with lines not,
datafile every 5 with points not,
1/0 with linespoints t "legend"

you'll have to add some statements so that all 3 plots use the same
color and/or pointtype, but i think it should work.

Karsten
--
Professur Modellierung und Simulation
Technische Universit�t Chemnitz, Fakult�t f�r Informatik
Stra�e der Nationen 62, Raum 366
Telefon: +49 371 531 - 37296

K. Lee

unread,
Feb 4, 2010, 12:40:59 PM2/4/10
to
On 2/4/2010 10:42 AM, Karsten Hentsch wrote:
> Am 03.02.2010 12:06, schrieb K. Lee:
>> On 2/2/2010 4:53 PM, Hans-Bernhard Br�ker wrote:
>>> K. Lee wrote:
>>>> Hello all,
>>>>
>>>> Since I have many points, it looks ugly if I draw my data set with
>>>> 'linespoints.' I can go with just 'lines,' but I'd like to put
>>>> points(markers) as well at every 5 or 10 data point. I hope someone
>>>> could help me do this in gnuplot. Thank you.
>>>
>>> Plot the file twice, once "with lines", then again "every 5 with
>>> points".
>>
>> Thank you for your advice. In that case, I'm afraid my legend would be
>> slightly incorrect, since it can have only either "line" or "point";
>> however, my line will have both "line" and "point" in a plot after
>> drawing twice.
>
> what about:
> plot
> datafile with lines not,
> datafile every 5 with points not,
> 1/0 with linespoints t "legend"
>
> you'll have to add some statements so that all 3 plots use the same
> color and/or pointtype, but i think it should work.
>
> Karsten

Thank you Karsten! That solved my problem. Now I have a perfect graph. :)

sfeam

unread,
Feb 4, 2010, 3:14:55 PM2/4/10
to
K. Lee wrote:

> On 2/4/2010 10:42 AM, Karsten Hentsch wrote:
>> Am 03.02.2010 12:06, schrieb K. Lee:

>>> On 2/2/2010 4:53 PM, Hans-Bernhard Bröker wrote:
>>>> K. Lee wrote:
>>>>> Hello all,
>>>>>
>>>>> Since I have many points, it looks ugly if I draw my data set with
>>>>> 'linespoints.' I can go with just 'lines,' but I'd like to put
>>>>> points(markers) as well at every 5 or 10 data point. I hope someone
>>>>> could help me do this in gnuplot. Thank you.
>>>>
>>>> Plot the file twice, once "with lines", then again "every 5 with
>>>> points".
>>>
>>> Thank you for your advice. In that case, I'm afraid my legend would be
>>> slightly incorrect, since it can have only either "line" or "point";
>>> however, my line will have both "line" and "point" in a plot after
>>> drawing twice.
>>
>> what about:
>> plot
>> datafile with lines not,
>> datafile every 5 with points not,
>> 1/0 with linespoints t "legend"
>>
>> you'll have to add some statements so that all 3 plots use the same
>> color and/or pointtype, but i think it should work.
>>
>> Karsten
>
> Thank you Karsten! That solved my problem. Now I have a perfect graph.
> :)

I'm glad you found a solution.

This is just a plug for the upcoming version gnuplot 4.4,
in which there is a new line property "pointinterval" that automates
this process. So in version 4.4 you will be able to accomplish what you
want by saying

plot datafile with linespoints pointinterval 5

Target schedule for release of 4.4 is next month, so you still have time
to try the release candidate and report problems requiring a last-minute
fix before final release :-)

0 new messages