|
From: Hernán De A. <var...@gm...> - 2026-03-29 10:22:43
|
You may already had this suggestion, as in using variables, but consider that given the length and complexity of your command, it is perhaps a better idea to use a script to do all steps from building your set of plot instructions, writing them to a configuration file, and then running the gnuplot command. I do this all the time to a good effect. /H. Den 2026-03-29 kl. 11:49, skrev Bjorn Buckwalter: > Thanks Jesper and Philpp. Jespers suggestion with variables can likely help > – I will try it! > > FYI here is an example plot command that fails: > > ``` > plot \ > 'world_110m.txt' using (lon($1)):(filter_lat($2)) with lines linecolor > "gray" notitle , \ > lat(0) with lines black dashtype 2 title "Equator" , \ > lat(66.6) with lines black dashtype 5 title "Arctic/Antarctic circle", \ > lat(-66.6) with lines black dashtype 5 notitle , \ > for [orbit in orbits] \ > 'data/Report'.orbit.'.txt' using (lon($7)):(filter_lat($6)) \ > with lines linecolor rgb next_color_t(n, 'cc') notitle, \ > for [orbit in orbits] \ > 'data/Report'.orbit.'.txt' using (lon($7)):($3 == 2030 ? > filter_lat($6) : NaN) \ > with lines linecolor rgb next_color(n) title orbit, \ > lat(lat1) black notitle # edge of plot > ``` > > There is A LOT going on there with various custom functions, etc. I tried > to make a minimal and “dependency-free” example but failed to reproduce the > behavior. I could maybe try harder. > > Here is in any case the error from gnuplot. The command has been > concatenated at all baskslashes except the last: > > ``` > plot 'world_110m.txt' using (lon($1)):(filter_lat($2)) with lines > linecolor "gray" notitle , lat(0) with lines black dashtype 2 title > "Equator" , lat(66.6) with lines black dashtype 5 title > "Arctic/Antarctic circle", lat(-66.6) with lines black dashtype 5 > notitle , for [orbit in orbits] 'data/Report'.orbit.'.txt' using > (lon($7)):(filter_lat($6)) with lines linecolor rgb next_color_t(n, > 'cc') notitle, for [orbit in orbits] 'data/Report'.orbit.'.txt' > using (lon($7)):($3 == 2030 ? filter_lat($6) : NaN) with lines > linecolor rgb next_color(n) title orbit, \ lat(lat1) black notitle # > edge of plot > > > > > > > > > ^ > "$plot_polar" line 15: invalid character \ > ``` > > There is nothing wrong with the backslash (no trailing spaces, etc.). > > If I change it as so (just shortening style definitions) it works: > > ``` > set style data lines > plot \ > 'world_110m.txt' using (lon($1)):(filter_lat($2)) lc "gray" notitle , \ > lat(0) black dt 2 title "Equator" , \ > lat(66.6) black dt 5 title "Arctic/Antarctic circle", \ > lat(-66.6) black dt 5 notitle , \ > for [orbit in orbits] \ > 'data/Report'.orbit.'.txt' using (lon($7)):(filter_lat($6)) \ > lc rgb next_color_t(n, 'cc') notitle, \ > for [orbit in orbits] \ > 'data/Report'.orbit.'.txt' using (lon($7)):($3 == 2030 ? > filter_lat($6) : NaN) \ > lc rgb next_color(n) title orbit, \ > lat(lat1) black notitle # edge of plot > ``` > > All I did was remove `with lines` (using `set style data lines` instead and > replace `linecolor` and `dashtype` with `lc` and `dt`, respectively. This > is why I say it seems to be somehow related to the length/number of > characters of a command. > > Thanks, > Bjorn > > > On Sun, Mar 29, 2026 at 5:28 AM Philipp K. Janert<ph...@ja...> wrote: > >> On Sat, 28 Mar 2026 22:13:40 +0100 >> Bjorn Buckwalter<bjo...@gm...> wrote: >> >>> HI all, >> How long (in characters) are the command lines that >> you are using? Mine frequently run long, and it has >> never been a problem. >> >> Is it possible that you have problems with embedded >> newlines, or that something goes awry if your command >> line runs into a new line in your terminal? >> >> Best, >> >> Ph. >> >>> I rather often run into a problem of my plot commands being too long, >>> typically resulting in a not-very-helpful error message such as: >>> >>> "$plot_polar" line 21: invalid character \ >>> >>> It took a lot of head scratching to realize the root of the problem. I >>> assume there are strong reasons for both the limitation on command >>> length and the poor error message. >>> >>> I cannot be the only one running into this problem. The situation >>> being what it is, what are the rest of you doing to manage when you >>> run up against this limit? Replacing `linecolor` with `lc`, etc, will >>> only get me so far and at the expense of readability. >>> >>> Many thanks, >>> Bjorn >>> >>> _______________________________________________ >>> gnuplot-info mailing list >>> gnu...@li... >>> Membership management via: >>> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> >> >> -- >> >> Philipp K. Janert >> www.janert.me >> >> >> _______________________________________________ >> gnuplot-info mailing list >> gnu...@li... >> Membership management via: >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via:https://lists.sourceforge.net/lists/listinfo/gnuplot-info |