|
From: Marc C. <mc...@un...> - 2022-01-23 13:55:00
|
hello people,
I'm considering using gnuplot to replace bc in some cases.
There the for loop can be used for ploting and setting things.
as the help says
plot for [filename in "A.dat B.dat C.dat"] filename using 1:2 with lines
plot for [basename in "A B C"] basename.".dat" using 1:2 with lines
set for [i = 1:10] style line i lc rgb "blue"
unset for [tag = 100:200] label tag
however, it can't be used with print and the do loop requires {} even
for 1 instruction. so when (what i think as) the "natural way" for
a gnuplot beginner is
f(x) = 2 * x + 3
print for [ x = 0:20:2 ] x, f(x)
i have to write
f(x) = 2 * x + 3
do for [ x = 0:20:2 ] {print x, f(x) }
is there an internal/conceptual reason for print to not work like the
others instructions?
also: i would like to suggest adding some examples in the gnuplot help
print section:
Syntax:
print <expression> {, <expression>, ...}
to demonstrate that's it's easy to cast a num as string by using "".
my update should be
Syntax:
print <expression> {, <expression>, ...}
Examples:
# print some text data
print "hello world"
# print some numeric data
x=12
print 12,x
# print combined data (first element *must* be a string)
print "".x." was the result"
also: i would like to know if there is a way to choose the expression
separator. so i can write
print x, f(x), g(x)
instead of
print "".x. ",".f(x). ",".g(x)
thanks for helping.
regards,
--
Marc Chantreux
Direction du numérique de l'Université de Strasbourg
Pôle de Calcul et Services Avancés à la Recherche (CESAR)
http://annuaire.unistra.fr/p/20200
|