4

I want to plot a file with linespoints in Gnuplot but the line using all the data samples and the points using fewer data samples. For example the following file plots the data but the line is not visible at all.

set terminal png
set out "plot_sample.png"
plot [t=-1000:1000] t w linespoints pt 64 lt 10 ps 1.5

How to do it if I want to define a custom sampling interval for the points but use all the data samples for the line? I could do two separate plots in the same figure but then the key will show both of them separately.

2 Answers 2

10

Use pointinterval to reduce the number of plotted points, but keep all points for drawing the line:

set samples 100
plot x**2 w linespoints pointinterval 10
Sign up to request clarification or add additional context in comments.

4 Comments

you've beaten me m(_ _)m
@gnzlbg pointinterval is an option specific to linespoints. To plot only every tenth point, use plot ... every 10 with points
But the every command only works for data points, right? What if you want to plot a function with points and control the point density?
@Martin That's what ``set samples` does
2
  • Use every to reduce the samples taken from file!
  • Plot the line and the points in two part, and use notitle at one of them!
  • Don't forget to 'synchronize' the color of the 2 plots!

Something like:

plot [t=-1000:1000] 'data.dat' w l lt 10 lc 10 t 'something', '' every 10 w p pt 64 ps 1.5 lc 10 notitle

NOTES

Usage of every: plot 'alma.dat' every A:B:C:D:E:F

where

  • A is the data increment (every Ath)
  • B is the datablock increment (datablocks are separated by empty lines)
  • C/D is the first data/datablock (start from C/D)
  • E/F is the last data/datablock (end at E/F)

You can use all the features described above, but if you don't need, just leave it empty, eg. ...every 2 or every 2::1 or every 2::1:0 ect...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.