I have a quite long gnuplot script. For debugging purposes, I would like to be able to block comment parts of this script or use a "goto" statement. Is this possible?
I know I can use an if
statement:
if (1 == 2) {
commented-out-code
} else {
non-commented-out code
}
Is this the only solution?
Gnuplot is a free, command-driven, interactive, function and data plotting program. Pre-compiled executeables and source code for Gnuplot 4.2. 4 may be downloaded for OS X, Windows, OS2, DOS, and Linux.
gnuplot can be used from various programming languages to graph data, including Perl (via PDL and other CPAN packages), Python (via gnuplotlib, Gnuplot-py and SageMath), R via (Rgnuplot), Julia (via Gaston.
5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).
There are two ways to save your work in gnuplot: you can save the gnuplot commands used to generate a plot, so that you can regenerate the plot at a later time. Or you can export the graph to a file in a standard graphics file format, so that you can print it or include it in web pages, documents, or presentations.
Comments in gnuplot start with a #
. If you want to comment a whole block, your text editor should be able to do that (e.g. M-; in Emacs with the block selected).
Gnuplot doesn't support block comments (as of version 5). But since Gnuplot interprets your script, the solution you gave does the job. But instead of using an expression to be falsified (evaluated to 0
), use a maximally obvious notation (for safety add a comment for its purpose). Spare the else
block as it's noting but complicating things.
Look on the following example, to see that it's not as easy as one might think.
if (0) { # commented-out block
This block is completely ignored by Gnuplot.
Well, obviously not completely...
# }{
...because Gnuplot is not just looking for the closing curly brace ;-)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With