suppose I want to plot a graph and I want to show on the graph some important points. How do I do this in gnuplot? For example, in the graph of y = x2, I want to show (2,4) and (4,16).
migrated from stackoverflow.com Jun 4 '10 at 5:18
This question came from our site for professional and enthusiast programmers.
I don't think the above answer is very helpful because, as I am writing this, the first google result method is extremely unsatisfactory.
It uses gnuplot's ability to read stdout to generate data, so that
will put a single data point at the point x=1, y=2.
This has several shortcomings that make it just about unusable.
First, there isn't a good way to pass variables into this method, because it already makes use of both types of quotes. The use of macros to pass variables in sprintf statements is therefore disabled, because a third type of quoting would be necessary.
Second, it requires the plot command to be run in order to call the point into existence. This means that if there is more than one point I want to plot, I have to append plot statements to the main plot statement. If I want to do this in any kind of scripted way, instead of just as an explicit list, I'm back to having to run a macro, which as I've already pointed out, doesn't work for this technique.
Gnuplot does have two techniques that are much more suitable to producing a single point.
First, if you just need a marker at a point, you can use the gnuplot object type to plot a circle at the point, e.g.
Second, if you really need a marker with a particular point style, you can use gnuplot's
sets a point with tag index
In this way, multiple points to be plotted can be set, and a separate plot command for another function can be issued without having to clutter the plot statement with all the single points to be plotted.
1st result for Googling gnuplot plot single point.
First you need to define the function to plot
Now you can customize your rendering as you wich.