|
From: Philipp K. J. <ph...@ja...> - 2026-03-29 18:03:08
|
On Sun, 29 Mar 2026 19:25:16 +0200
Bjorn Buckwalter <bjo...@gm...> wrote:
> Hi Philipp and all,
Bjorn -
At this point, I really think reproducability
is key.
Nothing I have seen so far suggests that there
is a problem with an arbitrary length limitation
w/in gnuplot. Instead, something seems to be
wrong in the very complicated command, function,
variable situation that you maintain.
Two things:
- Maybe you should go back and try to build up
your command again from scratch, one bit at a
time? And notice when and where it starts to
break?
- On a more strategic level: my recommendation
would be to move some, if not most, of the
data processing OUT of gnuplot, so that you
have a data file with the actual data that
you want to plot. In the long run, this will
probably turn out to be a better workflow.
Best,
Ph.
>
> So, trying to minimize a bit more, I realized that a key piece of
> information that was omitted seems to be that the plot command is
> inside a function block. Below is a case that reproduces the error
> for me that you could test. I realised that if I take the command out
> of the function it works properly.
>
> By the way I am on macos and `gnuplot --version` says `gnuplot 6.0
> patchlevel 4`.
>
> Here is the case that fails with the error in question. Since it fails
> early (at least for me) you will not actually need the data files:
>
> ```
> local lon(x) = x
> local lat(x) = x
> local filter_lat(x) = x
> local next_color(x) = "#00FF00"
> local next_color_t(x, y) = "#00FF00"
>
> local lat1 = 0
>
> function $plot_polar(orbits) <<EOF
> plot \
> 'world_110m.txt' using (lon($1)):(filter_lat($2)) linecolor "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(1, '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, \
> 0, \
> 1
> EOF
>
> _ = $plot_polar("A")
> ```
>
> The error message:
>
> ```
> plot 'world_110m.txt' using (lon($1)):(filter_lat($2)) linecolor
> "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(1, '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, 0, \ 1
>
>
>
>
>
>
> ^
> "$plot_polar" line 13: invalid character \
> ```
>
> If I change the `linecolor` in the first line of `plot` to `lc`, The
> error does not occur. If you test, you may instead get:
>
> ```
> "$plot_polar" line 13: warning: Cannot find or open file
> "world_110m.txt" "$plot_polar" line 13: warning: Cannot find or open
> file "data/ReportA.txt" "$plot_polar" line 13: warning: Cannot find
> or open file "data/ReportA.txt" "$plot_polar" line 13: undefined
> variable: orbit ```
>
> By the way, the last message is rather curious. I have had trouble
> where this pops up sometimes and I haven't been able to nail down the
> exact circumstances. I believe in this case that it refers to `title
> orbit`. If I change that to `notitle` it disappears. And changing
> from `notitle` to `title orbit` in the preceding line does not
> trigger the message. This seems also somehow related to the length of
> the command.
>
> I guess Hernán's suggestion to generate a “flat” gnuplot script with a
> non-gnuplot script could allow me to avoid using function blocks. (At
> least that is how I interpreted the suggestion).
>
> Thanks,
> Bjorn
>
>
> On Sun, Mar 29, 2026 at 2:24 PM Philipp K. Janert <ph...@ja...>
> wrote:
>
> > On Sun, 29 Mar 2026 11:49:01 +0200
> > Bjorn Buckwalter <bjo...@gm...> wrote:
> >
> > > Thanks Jesper and Philpp. Jespers suggestion with variables can
> > > likely help – I will try it!
> >
> > It's not so easy for me to reproduce your
> > problem, because I don't have access to the
> > data files, etc.
> >
> > The cmd does not seem overly long. I still
> > suspect that there is a problem with one of
> > the CRs not being properly escaped - such
> > as having a blank after a backslash, but
> > before the actual CR. The error msg in your
> > original email points to that, too.
> >
> > I did not dig into the code to see whether
> > there is an actual limit to the length of
> > the cmd line. Ethan would know.
> >
> > Do you enter the cmd interactively, or do
> > you have it in a file, which you load?
> >
> > >
> > > 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
> > > >
> >
> >
> >
> > --
> >
> > Philipp K. Janert
> > www.janert.me
> >
> >
> > _______________________________________________
> > gnuplot-info mailing list
> > gnu...@li...
> > Membership management via:
> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info
> >
--
Philipp K. Janert
www.janert.me
|