|
From: Gareth W. <gw...@ca...> - 2005-08-17 12:40:52
|
Hi, I am relatively new to gnuplot and don't pretend to know anything about its internals but some of the behaviour has been perplexing me. I can find very little information on the intended behaviour or philospohy of the program. I am developing a program that uses Octave (and hence gnuplot) to perform engineering calculations and display the results in a web broswer. To do this I need to output the plots to graphics file. The program is attempting to keep MATLAB and Octave compatibility for interactive use of each of the scripts, this riases issues of plot command ordering. In an interactive terminal (x11 in our case) this is of no consequence but when attempting to save the output to a file (I have used both png and SVG) the ordering is critical as the first plot command encountered outputs to the file, not allowing subsequent replots, clearing, adding of titles etc. This behaviour is not encountered by multiplots which seem to be constructed in a temporary terminal and then output once completed (signified by the unset multiplot). I cannot get this behaviour to be replicated for single plots however. From reading the postings here and on Soureforge I gather that the png terminal is usually piped to Imagemagick's display, and that the behaviour of most other file based terminals has been derrived from the png terminal's. It would appear to me that the strength of a file based terminal is the production of a finished plot, saved to a file for publishing, not real time viewing in an alternative format. Would it not therefore make sense to have the option that once a user enters a 'set term png', 'set output foo.png' to construct the plot as multiplot does, and then output the completed plot once the 'set output' command closes the file? Many thanks for your help, Gareth |
|
From: Daniel J S. <dan...@ie...> - 2005-08-18 19:18:35
|
Gareth,
> I am developing a program that uses Octave (and hence gnuplot) to perform
> engineering calculations and display the results in a web broswer.
>
> To do this I need to output the plots to graphics file. The program is
> attempting to keep MATLAB and Octave compatibility for interactive use of each
> of the scripts, this riases issues of plot command ordering.
>
> In an interactive terminal (x11 in our case) this is of no consequence but when
> attempting to save the output to a file (I have used both png and SVG) the
> ordering is critical as the first plot command encountered outputs to the file,
> not allowing subsequent replots, clearing, adding of titles etc.
gnuplot/Octave and Matlab is fairly consistent, but it can be frustrating. The biggest discrepancy I see is that gnuplot syntax changes plot properties (e.g., title) first and then plots. Matlab wants one to generate a plot first then change the properties. (Why, I don't know.) Yes this causes problems with multiplot.
You have to be creative with strategically placed
if exists('OCTAVE_VERSION')
graw('set term');
<or whatever other commands to gnuplot that you want>
end
and the like. Try turning off auto replot in Octave. Then Matlab/Octave might be good enough if you create a bogus Matlab plot first then issue title(), axis(), etc. I usually can manage to get what I want with code that will run in both Matlab and Octave.
Be aware that Octave is going through some changes as far as graphics commands, but I've not kept up. I'm afraid you will have to do what you can until a year or two down the road to see some re-emerging of gnuplot/Octave.
> This behaviour is not encountered by multiplots which seem to be constructed in
> a temporary terminal and then output once completed (signified by the unset
> multiplot). I cannot get this behaviour to be replicated for single plots
> however.
>
>>From reading the postings here and on Soureforge I gather that the png terminal
> is usually piped to Imagemagick's display, and that the behaviour of most other
> file based terminals has been derrived from the png terminal's. It would appear
> to me that the strength of a file based terminal is the production of a finished
> plot, saved to a file for publishing, not real time viewing in an alternative
> format.
>
> Would it not therefore make sense to have the option that once a user enters a
> 'set term png', 'set output foo.png' to construct the plot as multiplot does,
> and then output the completed plot once the 'set output' command closes the
> file?
I'm not following you. gnuplot is very flexible with screen and file plots.
Dan
|
|
From: Ethan M. <merritt@u.washington.edu> - 2005-08-18 19:44:00
|
On Wednesday 17 August 2005 05:21 am, Gareth Wilson wrote: > > In an interactive terminal (x11 in our case) this is of no consequence but when > attempting to save the output to a file (I have used both png and SVG) the > ordering is critical as the first plot command encountered outputs to the file, > not allowing subsequent replots, clearing, adding of titles etc. If you are happy with the x11 output, then I would hazard a guess that your best choice may be to bind a hot-key for x11 that issues a replot command to the file-based terminal of your choice: bind "ctrl-p" "set term png; set output 'myplot.png'; replot; set term x11" Then you can adjust the plot to your liking in an x window, and hit <control>p to save it to a file. For production work you'd need a more complicated binding that incremented the file name somehow. > This behaviour is not encountered by multiplots which seem to be constructed in > a temporary terminal and then output once completed (signified by the unset > multiplot). I cannot get this behaviour to be replicated for single plots > however. I'm afriad I don't recognize the symptoms you describe here. There is no temporary terminal involved in multiplot. > From reading the postings here and on Soureforge I gather that the png terminal > is usually piped to Imagemagick's display Well, it's the way *I* usually do it, at least if I'm sitting at the terminal. But primarily I use the png terminal in automated scripts at the back end of a web form, in which case they are not piped to ImageMagick but are saved as temporary files and linked back into a dynamically generated web page. > > Would it not therefore make sense to have the option that once a user enters a > 'set term png', 'set output foo.png' to construct the plot as multiplot does, > and then output the completed plot once the 'set output' command closes the > file? That is, in fact, the way they are normally used. Could you try to describe the probably you are having in more detail? I can't understand what multiplot has to do with anything. -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |
|
From: Juergen W. <wie...@fr...> - 2005-08-18 20:09:09
|
On Wednesday 17 August 2005 14:21 Gareth Wilson wrote:
> I am relatively new to gnuplot and don't pretend to know anything about its
> internals but some of the behaviour has been perplexing me. I can find very
> little information on the intended behaviour or philospohy of the program.
That's something I'm missing, too.
> In an interactive terminal (x11 in our case) this is of no consequence but
> when attempting to save the output to a file (I have used both png and SVG)
> the ordering is critical as the first plot command encountered outputs to
> the file, not allowing subsequent replots, clearing, adding of titles etc.
Think of it the following way: There are two kinds of file based
terminals: those which are capable of multi-page output files and
those which are not. If you do more then one plot/splot/replot
command in a row with a non-multi-page terminal, the result is
undefined. [If you ask me, gnuplot should issue a warning then.]
And the second point is: The state of the output file is undefined
as long as it isn't closed yet ("set output"). It may be valid in
advance (png), and it may not (postscript).
> This behaviour is not encountered by multiplots which seem to be
> constructed in a temporary terminal and then output once completed
> (signified by the unset multiplot). I cannot get this behaviour to be
> replicated for single plots however.
So the savest thing is to do:
set ...
...
set term ...
set output "..."
plot ...
set output
or
set ...
...
set term ...
set output "..."
set multiplot
set size ...
plot ...
set size ...
plot ...
unset multiplot
set output
If you need a valid file while plotting, set output to a temporary
file and rename it after the finishing "set output".
Juergen
|
|
From: Ethan M. <merritt@u.washington.edu> - 2005-08-18 20:28:10
|
On Thursday 18 August 2005 01:08 pm, Juergen Wieferink wrote: > > So the savest thing is to do: > > set ... > ... > > set term ... > set output "..." > plot ... > set output That depends on what you want to end up with. If you want all of your plots included in the same output file then you certainly don't want to close it after each one. In fact that will result in the plots over-writing each other and only the last plot will be saved in the end. The important distinction is whether a particular output format can contain multiple plots (NB: *not* multiplot) or not. A PostScript or PDF document can contain as many plots as you want, one per page. A PNG output file can contain only one plot. A GIF output file can contain multiple plots, but only if you describe them as an "animation". The current SVG terminal was not designed to handle multiple plots in the same output file; whatever you get in this case is undocumented and may not be repeatable. Inconsistent? I suppose so. But this is the nature of the output formats themselves. gnuplot cannot store multiple plots in an PNG image because the PNG standard itself does not provide for it. (Actually, there is an extension called MNG that does provide for multiple plots per file, but let's disregard that for now). -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |
|
From: Juergen W. <wie...@fr...> - 2005-08-19 06:11:33
|
Am Donnerstag, 18. August 2005 22:27 schrieb Ethan Merritt: > That depends on what you want to end up with. If you want > all of your plots included in the same output file then > you certainly don't want to close it after each one. > In fact that will result in the plots over-writing each > other and only the last plot will be saved in the end. I had the impression the OP wanted to have single-plot files---eventually, he uses PNG and SVG. So I discussed only "non-multi-page terminals". I should have been more clear about it. Thanks for the clarification. Juergen |