Mercurial > hg > octave-lojdl
changeset 1540:749b8b19733f
[project @ 1995-10-06 03:10:34 by jwe]
Initial revision
author | jwe |
---|---|
date | Fri, 06 Oct 1995 03:10:34 +0000 |
parents | 4914a8b34fd0 |
children | 47bd45a30dda |
files | scripts/plot/bottom_title.m scripts/plot/mplot.m scripts/plot/multiplot.m scripts/plot/oneplot.m scripts/plot/plot_border.m scripts/plot/subplot.m scripts/plot/subwindow.m scripts/plot/top_title.m scripts/plot/zlabel.m |
diffstat | 9 files changed, 711 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/scripts/plot/bottom_title.m @@ -0,0 +1,45 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function bottom_title (text) + +# usage: bottom_title (text) +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch +# +# makes a title with the given text at the bottom of the plot +# rather than the top. +# + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU + + if (nargin != 1) + usage ("bottom_title (text)"); + endif + + if (isstr (text)) + set top_title + set title + eval (sprintf ("set bottom_title \"%s\"", text)); + else + error ("bottom_title: text must be a string"); + endif + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/mplot.m @@ -0,0 +1,87 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function mplot (...) + +# usage: mplot (x, y) +# mplot (x1, y1, x2, y2, ...) +# mplot (x, y, fmt) +# +# This is a modified version of plot() command to work with +# multiplot version of gnuplot to plot multiple plots per page. +# This plot version automatically updates the plot position to +# next plot position after making the plot in the given subplot +# position. +# +# See command plot() for the various options to this command +# as this is just mulitplot version of the same command. + + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU + +# global variables to keep track of multiplot options + + global multiplot_mode + global multi_xsize multi_ysize + global multi_xn multi_yn + global multi_xi multi_yi + +# This is a real kludge. We gnuplot should be made so that replot can +# be executed while doing multiple plots... + + global multiplot_save_auto_replot = automatic_replot + + if ((isstr (automatic_replot) && strcmp (automatic_replot,"true")) + || automatic_replot) + warning ("turning off automatic replot for multiplot mode"); + multiplot_save_auto_replot = automatic_replot; + automatic_replot = 0; + endif + + set nologscale; + set nopolar; + + plot_int ("plot", all_va_args); + +# update the plot position + + if (multiplot_mode) + + if (multi_xi < multi_xn) + multi_xi++; + else + multi_xi = 1; + if (multi_yi < multi_xn) + multi_yi++; + else + multi_yi = 1; + endif + endif + + xo = (multi_xi - 1.0)*multi_xsize; + yo = (multi_yn - multi_yi)*multi_ysize; + + eval (sprintf ("set origin %g, %g", xo,yo)); + + endif + +endfunction + + +
new file mode 100644 --- /dev/null +++ b/scripts/plot/multiplot.m @@ -0,0 +1,115 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function multiplot (xn, yn) + +# usage: multiplot (xn, yn) +# +# Sets and resets multiplot mode +# +# If multiplot(0,0) then it will close multiplot mode and and if +# arguments are non-zero, then it will set up multiplot mode with +# xn,yn subplots along x and y axes. +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + +# global variables to keep track of multiplot options + + global multiplot_mode + global multi_xsize multi_ysize + global multi_xn multi_yn + global multi_xi multi_yi + +# This is a real kludge. We gnuplot should be made so that replot can +# be executed while doing multiple plots... + + global multiplot_save_auto_replot = automatic_replot + + if (nargin != 2) + usage ("multiplot (xn, yn)"); + endif + + if (! (is_scalar (xn) && is_scalar (yn))) + error ("multiplot: xn and yn have to be scalars"); + endif + + if ((isstr (automatic_replot) && strcmp (automatic_replot,"true")) + || automatic_replot) + warning ("turning off automatic replot for multiplot mode"); + multiplot_save_auto_replot = automatic_replot; + automatic_replot = 0; + endif + + xn = round (xn); + yn = round (yn); + + if (xn == 0 && yn == 0) + + set nomultiplot; + set size 1,1 + set origin 0,0 + + multiplot_mode = 0; + multi_xsize = 1; + multi_ysize = 1; + multi_xn = 1; + multi_yn = 1; + multi_xi = 1; + multi_yi = 1; + +# Someone may have reset it betweeen calls... + + if (! isstr (automatic_replot) && ! automatic_replot) + automatic_replot = multiplot_save_auto_replot; + endif + + return; + + else + + if (xn < 1 || yn < 1) + error ("multiplot: xn and yn have to be positive integers"); + endif + + set multiplot; + + xsize = 1.0 ./ xn; + ysize = 1.0 ./ yn; + + eval (sprintf ("set size %g, %g", xsize, ysize)); + + xo = 0.0; + yo = (yn - 1.0)*ysize; + + eval (sprintf ("set origin %g, %g", xo, yo)); + + multiplot_mode = 1; + multi_xsize = xsize; + multi_ysize = ysize; + multi_xn = xn; + multi_yn = yn; + multi_xi = 1; + multi_yi = 1; + + endif + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/oneplot.m @@ -0,0 +1,39 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function oneplot () + +# usage: oneplot +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch +# +# Switches from multiplot (if in multiplot mode) to single plot +# mode + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + + global multiplot_mode + + set nomultiplot; + set size 1, 1 + set origin 0, 0 + multiplot_mode = 0; + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/plot_border.m @@ -0,0 +1,98 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function plot_border (...) + +# usage: plot_border (...) +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch +# +# Multiple arguments allowed to specify the sides on which the border +# is shown. allowed strings: +# +# allowed input strings: +# +# "blank", "BLANK", "b", "B", ---> No borders displayed +# "all", "ALL", "a", "A", ---> All borders displayed +# "north", "NORTH", "n", "N", ---> North Border +# "south", "SOUTH", "s", "S", ---> South Border +# "east", "EAST", "e", "E", ---> East Border +# "west", "WEST", "w", "W", ---> West Border +# +# Without any arguments, turns borders off. + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + + south = 0; + west = 0; + north = 0; + east = 0; + all = 0; + none = 1; + + va_start (); + + while (nargin--) + + arg = va_arg (); + + if (! isstr (arg)) + error ("plot_border: input not a string"); + endif + +# The effect of the arguments in cumulative. If something is found +# after "b", do that and ignore "b". + + if (strcmp (arg, "blank") || strcmp (arg, "BLANK") + || strcmp (arg, "b") || strcmp (arg, "B")) + none = 1; + else + none = 0; + if (strcmp (arg, "south") || strcmp (arg, "SOUTH") + || strcmp (arg, "s") || strcmp (arg, "S")) + south = 1; + elseif (strcmp (arg, "west") || strcmp (arg, "WEST") + || strcmp (arg, "w") || strcmp (arg, "W")) + west = 2; + elseif (strcmp (arg, "north") || strcmp (arg, "NORTH") + || strcmp (arg, "n") || strcmp (arg, "N")) + north = 4; + elseif (strcmp (arg, "east") || strcmp (arg, "EAST") + || strcmp (arg, "e") || strcmp (arg, "E")) + east = 8; + elseif (strcmp (arg, "all") || strcmp (arg, "ALL") + || strcmp (arg, "a") || strcmp (arg, "A")) + all = 1; + endif + endif + endwhile + + if (none) + set noborder + else + if (all) + border = 15; + else + border = south + west + north + east; + endif + eval (sprintf ("set border %d", border)); + endif + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/subplot.m @@ -0,0 +1,170 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function subplot (rows, columns, index) + +# usage: subplot (rows, columns, index) +# subplot (rcn) +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch (or version 3.6 beta) +# +# Sets gnuplot in multiplot mode and plots in location +# given by index (there are columns X rows subwindows) +# +# Input: +# +# rows : number of rows in subplot grid +# columns: number of columns in subplot grid +# index : index of subplot where to make the next plot +# +# If only one arg, then it (crn) has to be three digit value +# specifying the location in digit 1 (rows) and 2 (columns) and digit +# 3 is the plot index +# +# The plot index runs row-wise,i.e., first all the columns in a row +# are filled and then the next row is filled +# +# For example, plot with 4 X 2 grid, will have plot indices running as +# follows: +# +# ----------------------------------- +# | | | | | +# | 1 | 2 | 3 | 4 | +# | | | | | +# ----------------------------------- +# | | | | | +# | 5 | 6 | 7 | 8 | +# | | | | | +# ----------------------------------- +# + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU + +# global variables to keep track of multiplot options + + global multiplot_mode + global multi_xsize multi_ysize + global multi_xn multi_yn + global multi_xi multi_yi + +# This is a real kludge. We gnuplot should be made so that replot can +# be executed while doing multiple plots... + + global multiplot_save_auto_replot = automatic_replot + + if (nargin != 3 && nargin != 1) + usage ("subplot (rows, columns, index) or subplot (rcn)"); + endif + + if ((isstr (automatic_replot) && strcmp (automatic_replot, "true")) + || automatic_replot) + warning ("turning off automatic replot for multiplot mode"); + multiplot_save_auto_replot = automatic_replot; + automatic_replot = 0; + endif + + if (nargin == 1) + + if (! is_scalar (rows)) + error ("subplot: input rcn has to be a scalar"); + endif + + xnp = rows; + rows = round (xnp/100); + columns = round ((xnp - 100*rows)/10); + index = xnp - 10*columns - 100*rows; + + elseif (! (is_scalar (columns) && is_scalar (rows) && is_scalar (index))) + error ("subplot: columns, rows, and index have to be scalars"); + endif + + columns = round (columns); + rows = round (rows); + index = round (index); + + if (index > columns*rows) + error ("subplot: index must be less than columns*rows"); + endif + + if (columns < 1 || rows < 1 || index < 1) + error ("subplot: columns,rows,index must be be positive"); + endif + + if (columns*rows == 1) + +# switching to single plot ? + + set nomultiplot; + set size 1,1 + set origin 0,0 + + multi_xn = 1; + multi_yn = 1; + multiplot_mode = 0; + +# Someone may have reset it betweeen calls... + + if (! isstr (automatic_replot) && ! automatic_replot) + automatic_replot = multiplot_save_auto_replot; + endif + + return; + + endif + +# doing multiplot plots + + doagain = 0; + + if (exist ("multiplot_mode") != 1) + doagain = 1; + elseif (multiplot_mode != 1 || multi_xn != columns || multi_yn != rows) + doagain = 1; + endif + + if (doagain) + + multiplot_mode = 1; + multi_xn = columns; + multi_yn = rows; + multi_xsize = 1.0 ./ columns; + multi_ysize = 1.0 ./ rows; + + set multiplot; + + eval (sprintf ("set size %g, %g", multi_xsize, multi_ysize)); + + endif + +# get the sub plot location + + yp = round ((index-1)/columns); + xp = index - yp*columns - 1; + multi_xi = ++xp; + multi_yi = ++yp; + +# set the origin + + xo = (xp - 1.0)*multi_xsize; + yo = (rows - yp)*multi_ysize; + + eval (sprintf ("set origin %g, %g", xo, yo)); + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/subwindow.m @@ -0,0 +1,73 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function subwindow (xn, yn) + +# usage: subwindow (xn, yn) +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch +# +# Sets subwindow position in multiplot mode for next plot. The +# multiplot mode has to be previously initialized using multiplot() +# command, else this command just becomes an aliad to multiplot() + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + +# global variables to keep track of multiplot options + + global multiplot_mode + global multi_xsize multi_ysize + global multi_xn multi_yn + +# check calling argument count + + if (nargin != 2) + usage ("subwindow (xn, yn)"); + endif + +# check for scalar inputs + + if (! (is_scalar (xn) && is_scalar (yn))) + error ("subwindow: xn and yn have to be scalars"); + endif + + xn = round (xn); + yn = round (yn); + +# switch to multiplot mode if not already in, and use the args as the +# args to multiplot() + + if (multiplot_mode != 1) + multiplot (xn, yn) + return; + endif + +# get the sub plot location + + if (xn < 1 || xn > multi_xn || yn < 1 || yn > multi_yn) + error ("subwindow: incorrect xn and yn"); + endif + + xo = (xn - 1.0)*multi_xsize; + yo = (multi_yn - yn)*multi_ysize; + + eval (sprintf ("set origin %g, %g", xo, yo)); + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/top_title.m @@ -0,0 +1,43 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function top_title (text) + +# usage: top_title (text) +# +# NOTE: this will work only with gnuplot installed with +# multiplot patch +# +# makes a title with text "text" at the top of the plot + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + + if (nargin != 1) + usage ("top_title (text)"); + endif + + if (isstr (text)) + set bottom_title + set title + eval (sprintf ("set top_title \"%s\"", text)); + else + error ("error: top_title: text must be a string"); + endif + +endfunction
new file mode 100644 --- /dev/null +++ b/scripts/plot/zlabel.m @@ -0,0 +1,41 @@ +# Copyright (C) 1995 John W. Eaton +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +function zlabel (text) + +# usage: zlabel (text) +# +# Defines a label for the z-axis of a plot. The label will appear the +# next time a plot is displayed. +# +# See other plotting commands also. + +# Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 + + if (nargin != 1) + usage ("zlabel (text)"); + endif + + if (isstr (text)) + eval (sprintf ("set zlabel \"%s\"", text)); + else + error ("error: zlabel: text must be a string"); + endif + +endfunction