From octave-sources-request at bevo dot che dot wisc dot edu Fri Apr 11 10:06:01 2003 Subject: Colormap for z-coloured surf plot (gnuplot 3.8+) From: fabio rainone To: octave-sources at bevo dot che dot wisc dot edu Date: Fri, 11 Apr 2003 03:15:41 -0500 Hi folks!! I just derived from colormap a new function that is capable to modify the palette used by the new 3D plot function in GNUplot, pm3d. This allow very good mimicking of the MATLAB surf/colormap capabilities ## Copyright (C) 2003 Fabio Rainone ## ## This program 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 of the License, or ## (at your option) any later version. ## ## This program 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 this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## -*- texinfo -*- ## at deftypefn {Function File} {} gcolormap(@var{map}) ## at deftypefnx {Function File} {} gcolormap("default") ## at code{gcolormap(@var{map})} sets the current colormap for z-coloured plots ## in Gnuplot 3.8+. at var{map} should be an @var{n} row per 3 column vector. ## Each row contains an RGB triplet expressed in the range [0, 1] ## ## at code{gcolormap("default") sets the colormap to the default (grayscale) ## ## With no arguments, at code{gcolormap} returns the current colormap ## at end deftypefn ## at seealso {colormap} ## Author: Fabio Rainone ## LGRC - EPFL - Switzerland ## Created April 2003 function rmap = gcolormap(map) global __gnuplot_colormap__= gray(); ##Bad argument list if(nargin>1) usage("gcolormap (map)"); endif if (nargin ==1) #The palette is given by name if(isstr(map)) if(strcmp(map, "default")) map = gray(); elseif(exist(map)==2) ##if map is a function file unwind_protect save__eval_print_flag = default_eval_print_flag; default_eval_print_flag = 0; map = eval(map); unwind_protect_cleanup default_eval_print_flag = save__eval_print_flag; end_unwind_protect else ##any other case is a error error("gcolormap: unknown colormap function"); endif ##exist(map) endif ##isstr(map) ##The palette is given as matrix if( isempty(map) || (columns(map)~=3) ) error("gcolormap: Palette matrix must be 3 columns wide!") elseif (min (map(:)) < 0 || max (map(:)) > 1) error("gcolormap: r g b must be scaled in [0 1] range"); else __gnuplot_colormap__ = map; endif try gset palette model RGB file "-" graw ([sprintf("%5.4f %5.4f %5.4f\n", __gnuplot_colormap__') "e\n"]); catch end_try_catch endif ## nargin==1 rmap = __gnuplot_colormap__; endfunction Fabio Rainone, SB - ISP - LGRC Swiss Federal Institute of Technology CH-1015 Lausanne (Switzerland)