That makes no sense at all. Perhaps you are confusing "with" with some other keyword?
The possible values for "with" are plot styles like "lines", "histograms", "boxplot", etc. Each of these requires a different set of input values.
Nevertheless if you really want to put the plot style in a variable you can do that using macros:
set macro
with(n) == 1 ? "lines" : with(n) == 2 ? "points" : "impulses"
style = with(n)
plot FOO with @style
This won't work in the kind of loop you showed, however.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the reply. I really mean the actual "with".
Macro does not work here cause it is only interpreted statically before execution.
I think this feature is really useful when you are plotting many series in a same plot. You can then use a function to dynamically decide the plot styles (points, lines, linepoints, etc..).
Here is a typical scenario:
You want to plot 30 series in a same plot from a datafile. The datafile is in such a format:
Series 1: results estimated from method1 on day 1
Series 2: results estimated from method2 on day 1
Series 3: results from actual measurement on day 1
Series 4: results estimated from method1 on day 2
Series 5: results estimated from method2 on day 2
Series 6: results from actual measurement on day 2
.....
You want to plot results estimated from method1 using lines, that from method2 using linepoints. And plot results from actual measurement using points.
If "with" supports function input, this scenario can be accomplished as:
title(i)=value(sprintf("title%i",i mod 3))
title0='method1'
title1='method2'
title2='measurement'
with(i)=value(sprintf("with%i",i mod 3))
with0='lines'
with1='linepoints'
with2='points'
plot for [i=1:30] '-' title title(i) with with(i) ls i
Besides, I am using java to general gnuplot code. The lack of ability to use variables/function to represent the with type of a series in a plot is now the only problem preventing me to create a flexible gnuplot code template.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you set the linewidth of the linepoints type to mimic the option of "with points". The number of available point types that can be seen is then only 5. Only these filled point types (5, 7, 9, 11, 13) can be seen. All other point types can not be seen when the linewidth is set to be very small.
Is there a way to work around?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Clean separation of all of the line/point properties is one of the issues being worked on for version 5. In fact it's the major issue holding up the release. So while I can tell you that there will be several ways to do this in version 5, they aren't available in current versions.
For certain terminal types you could fix this locally. For instance, you could add a line in the local PostScript prologue.ps file that would make the linewidth used for drawing points separate from the one used for the lines.
On the other hand, even with the current imperfect implementation a huge number of distinct linetypes can be defined and used. See for instance the last demo plot in http://gnuplot.sourceforge.net/demo/dashcolor.html
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That makes no sense at all. Perhaps you are confusing "with" with some other keyword?
The possible values for "with" are plot styles like "lines", "histograms", "boxplot", etc. Each of these requires a different set of input values.
Nevertheless if you really want to put the plot style in a variable you can do that using macros:
set macro
with(n) == 1 ? "lines" : with(n) == 2 ? "points" : "impulses"
style = with(n)
plot FOO with @style
This won't work in the kind of loop you showed, however.
Thanks for the reply. I really mean the actual "with".
Macro does not work here cause it is only interpreted statically before execution.
I think this feature is really useful when you are plotting many series in a same plot. You can then use a function to dynamically decide the plot styles (points, lines, linepoints, etc..).
Here is a typical scenario:
You want to plot 30 series in a same plot from a datafile. The datafile is in such a format:
Series 1: results estimated from method1 on day 1
Series 2: results estimated from method2 on day 1
Series 3: results from actual measurement on day 1
Series 4: results estimated from method1 on day 2
Series 5: results estimated from method2 on day 2
Series 6: results from actual measurement on day 2
.....
You want to plot results estimated from method1 using lines, that from method2 using linepoints. And plot results from actual measurement using points.
If "with" supports function input, this scenario can be accomplished as:
title(i)=value(sprintf("title%i",i mod 3))
title0='method1'
title1='method2'
title2='measurement'
with(i)=value(sprintf("with%i",i mod 3))
with0='lines'
with1='linepoints'
with2='points'
plot for [i=1:30] '-' title title(i) with with(i) ls i
Besides, I am using java to general gnuplot code. The lack of ability to use variables/function to represent the with type of a series in a plot is now the only problem preventing me to create a flexible gnuplot code template.
This is already possible for the subset of styles lines and points. For other styles I don't think it makes any sense.
Thanks for the reply.
It is really useful. I did not know that.
Thanks.
I found a serious problem for this approach.
If you set the linewidth of the linepoints type to mimic the option of "with points". The number of available point types that can be seen is then only 5. Only these filled point types (5, 7, 9, 11, 13) can be seen. All other point types can not be seen when the linewidth is set to be very small.
Is there a way to work around?
Clean separation of all of the line/point properties is one of the issues being worked on for version 5. In fact it's the major issue holding up the release. So while I can tell you that there will be several ways to do this in version 5, they aren't available in current versions.
For certain terminal types you could fix this locally. For instance, you could add a line in the local PostScript prologue.ps file that would make the linewidth used for drawing points separate from the one used for the lines.
On the other hand, even with the current imperfect implementation a huge number of distinct linetypes can be defined and used. See for instance the last demo plot in
http://gnuplot.sourceforge.net/demo/dashcolor.html
Thanks for the reply again. I always love & believe in gnuplot because of you guys.