From octave-graphics-request at bevo dot che dot wisc dot edu Thu Feb 10 03:12:05 2000 Subject: Adding output for other plotting programs From: "John W. Eaton" To: Peter Hopfgartner Cc: octave-graphics at bevo dot che dot wisc dot edu Date: Thu, 10 Feb 2000 03:11:53 -0600 (CST) On 27-Dec-1999, Peter Hopfgartner wrote: | I've posted recently some scripts to output results with superficie | (plot3, quiver3, surf) and played a bit with an output with the | GNU plotutils. | | Anyway, I was wondering, if there is any kinf of infrastructure in | Octave 2.1.x for multiple packages. | | In particular, how should these kind of new interfaces be added. | | Should the plot/mesh etc command read an environment variable to chose | which package to use? Or should they simply have sightlly different | names? | | How should I access the informations for titles, axis labels etc? These are all good questions, and unfortunately I don't have have good answers for them. | Is this work welcomed? Yes. I think the plotting interfaces will eventually have to be rewritten almost completely. The current interface to gnuplot is really starting to bug me. The following outlines one reason why (I sent it to the gnuplot maintainer). I finally started trying to have Octave send data to gnuplot without creating temporary files and ran into some problems. Currently, for each pair of x-y data in a command like plot (x1, y1, x2, y2, x3, y3, ..., xn, yn) Octave creates a temporary file and then generates a command like plot "/tmp/fileXXX" for the first line and replot "/tmp/fileYYY" for the remaining lines. This works fine for data stored in files, but it doesn't work if the data are sent to gnuplot along with the commands. In other words, plot "/tmp/fileXXX" replot "/tmp/fileYYY" works, but plot '-' 1 2 ... e replot '-' 3 4 ... e does not (it seems that gnuplot expects to see the data for the first line again). For this particular case, Octave could be fixed to save all the data in temporary files and then generate a single plot command that looks like this: plot "/tmp/fileXXX", "/tmp/fileYYY" If that were all, then I would go ahead and try to make these changes, but there is one more twist. Octave has a feature (patterned after a similar feature in Matlab) that allows one to add lines to an existing plot by using plot (x1, y1) hold on plot (x2, y2) In this case, the first plot must be displayed, then the second line added to it. Currently, Octave's method of using temporary files does this correctly. The first plot command generates a temporary file and a plot "/tmp/fileXXX" command for gnuplot. Then the second plot command generates another temporary file and a replot "/tmp/fileYYY" for gnuplot (even though it is the first curve for the current call to the plot function, `replot' is used instead of `plot' because the `hold' state is `on'). This works great. Gnuplot remembers the name of the previous file and both lines are displayed on the plot. But if I send the data along with the plot commands, because gnuplot wants to see all the data and I only have one set (x2, y2). The fix is not impossible, but it is a little messy. Octave would have to hang on to the last set of plot data just in case a new plot might be made with the `hold' state `on'. If there is no other way, I can probably arrange for this to work in Octave, but since gnuplot already remembers the names of files that it has previously plotted, would it be possible, when the data are coming from the command stream, to have it remember the data that it last used as well? What do you think? Thanks, jwe So, I'm ready to start thinking about how to improve things so that other plotting packages can be easily supported within Octave. I don't care about supporting the gplot/gsplot interface with other plotting packages though, so people who are using that will have to be stuck with gnuplot. Anything else would be too hard, I think. But people who use the plot() commands (or some other better set of plotting functions) should not be forced to use any particular plotting package. The design needs to relatively clean. We can't have every plotting package implementing every detail of plotting. Lots of code needs to be shared, otherwise I think it is too hard to incorporate new packages. Any ideas? jwe