Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block comments in gnuplot

Tags:

gnuplot

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?

like image 320
Miguel Avatar asked Jan 20 '15 16:01

Miguel


People also ask

What is gnuplot command?

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.

Does R use gnuplot?

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.

Does gnuplot support multiple Y axes on a single plot?

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).

How do I save in gnuplot?

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.


2 Answers

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).

like image 85
choroba Avatar answered Oct 19 '22 08:10

choroba


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 ;-)
}
like image 35
Wolf Avatar answered Oct 19 '22 09:10

Wolf