[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
individual colormaps per subplots
From: |
Daniel J Sebald |
Subject: |
individual colormaps per subplots |
Date: |
Tue, 19 Jun 2007 16:48:50 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 |
Attached is a patch that moves the colormap from figure to axes. I'm guessing
it wouldn't be too uncommon for a user to want to have two images on the screen
with different colormaps. For example:
subplot(2,1,1);
image;
colormap(gray(64));
subplot(2,1,2);
image;
colormap(ocean(64));
This requires the latest CVS version of gnuplot as there was just an upgrade to
allow multiple colormaps in X11. Most other file-based terminals should work.
There may be some GUI-based terminals that don't yet work. If so, let me know.
Dan
scripts/ChangeLog:
2007-06-19 Daniel J. Sebald <address@hidden>
* plot/__go_draw_axes__.m plot/contour.c image/colormap.m: User current
axes rather than current figure to access colormap.
src/ChangeLog:
2007-06-19 Daniel J. Sebald <address@hidden>
* graphics.cc (axes::axes_properties::axes_properties)
(axes::axes_properties::set, axes::axes_properties::get)
(axes::axes_properties::factory_defaults)
(figure::figure_properties::figure_properties)
(figure::figure_properties::set, figure::figure_properties::get)
(figure::figure_properties::factory_defaults)
graphics.h (axes, figure): Moved colormap from figure to axes so there
can be individual colormaps for subplots.
Also note that there is a group of 8 spaces that should be a tab in the first
entry of src/ChangeLog.
diff -Pur octave-cvs/scripts/image/colormap.m
octave-mod/scripts/image/colormap.m
--- octave-cvs/scripts/image/colormap.m 2007-01-30 13:16:52.000000000 -0600
+++ octave-mod/scripts/image/colormap.m 2007-06-19 16:12:02.000000000 -0500
@@ -61,12 +61,12 @@
error ("colormap: map must have values in [0,1]");
endif
## Set the new color map
- set (gcf (), "colormap", map);
+ set (gca (), "colormap", map);
endif
endif
## Return current color map.
- cmap = get (gcf (), "colormap");
+ cmap = get (gca (), "colormap");
endfunction
diff -Pur octave-cvs/scripts/plot/contour.m octave-mod/scripts/plot/contour.m
--- octave-cvs/scripts/plot/contour.m 2007-05-02 00:36:43.000000000 -0500
+++ octave-mod/scripts/plot/contour.m 2007-06-19 16:12:20.000000000 -0500
@@ -46,7 +46,7 @@
[c, lev] = contourc (varargin{:});
- cmap = get (gcf(), "colormap");
+ cmap = get (gca(), "colormap");
levx = linspace (min (lev), max (lev), size (cmap, 1));
diff -Pur octave-cvs/scripts/plot/__go_draw_axes__.m
octave-mod/scripts/plot/__go_draw_axes__.m
--- octave-cvs/scripts/plot/__go_draw_axes__.m 2007-06-19 01:00:08.000000000
-0500
+++ octave-mod/scripts/plot/__go_draw_axes__.m 2007-06-19 16:12:13.000000000
-0500
@@ -30,8 +30,6 @@
axis_obj = get (h);
- parent_figure_obj = get (axis_obj.parent);
-
persistent have_newer_gnuplot ...
= compare_versions (__gnuplot_version__ (), "4.0", ">");
@@ -68,7 +66,6 @@
if (! isempty (axis_obj.xlabel))
t = get (axis_obj.xlabel);
- angle = t.rotation;
if (isempty (t.string))
fputs (plot_stream, "unset xlabel;\n");
else
@@ -77,6 +74,7 @@
if (have_newer_gnuplot)
## Rotation of xlabel not yet support by gnuplot as of 4.2, but
## there is no message about it.
+ angle = t.rotation;
fprintf (plot_stream, " rotate by %f", angle);
endif
fputs (plot_stream, ";\n");
@@ -85,13 +83,13 @@
if (! isempty (axis_obj.ylabel))
t = get (axis_obj.ylabel);
- angle = t.rotation;
if (isempty (t.string))
fputs (plot_stream, "unset ylabel;\n");
else
fprintf (plot_stream, "set ylabel \"%s\"",
undo_string_escapes (t.string));
if (have_newer_gnuplot)
+ angle = t.rotation;
fprintf (" rotate by %f;\n", angle);
endif
fputs (plot_stream, ";\n");
@@ -100,7 +98,6 @@
if (! isempty (axis_obj.zlabel))
t = get (axis_obj.zlabel);
- angle = t.rotation;
if (isempty (t.string))
fputs (plot_stream, "unset zlabel;\n");
else
@@ -109,6 +106,7 @@
if (have_newer_gnuplot)
## Rotation of zlabel not yet support by gnuplot as of 4.2, but
## there is no message about it.
+ angle = t.rotation;
fprintf (plot_stream, " rotate by %f;\n", angle);
endif
fputs (plot_stream, ";\n");
@@ -214,7 +212,7 @@
endif
img_data = obj.cdata;
- img_colormap = parent_figure_obj.colormap;
+ img_colormap = axis_obj.colormap;
img_xdata = obj.xdata;
img_ydata = obj.ydata;
diff -Pur octave-cvs/src/graphics.cc octave-mod/src/graphics.cc
--- octave-cvs/src/graphics.cc 2007-06-15 13:21:22.000000000 -0500
+++ octave-mod/src/graphics.cc 2007-06-19 16:11:53.000000000 -0500
@@ -747,7 +747,6 @@
nextplot ("replace"),
closerequestfcn (make_fcn_handle ("closereq")),
currentaxes (octave_NaN),
- colormap (),
visible ("on"),
paperorientation ("portrait")
{ }
@@ -780,8 +779,6 @@
else
gripe_set_invalid ("currentaxes");
}
- else if (name.compare ("colormap"))
- colormap = colormap_property (val);
else if (name.compare ("visible"))
{
std::string s = val.string_value ();
@@ -819,7 +816,6 @@
m.assign ("nextplot", nextplot);
m.assign ("closerequestfcn", closerequestfcn);
m.assign ("currentaxes", nan_to_empty (currentaxes));
- m.assign ("colormap", colormap);
m.assign ("visible", visible);
m.assign ("paperorientation", paperorientation);
@@ -847,8 +843,6 @@
retval = closerequestfcn;
else if (name.compare ("currentaxes"))
retval = nan_to_empty (currentaxes);
- else if (name.compare ("colormap"))
- retval = colormap;
else if (name.compare ("visible"))
retval = visible;
else if (name.compare ("paperorientation"))
@@ -883,7 +877,6 @@
m["nextplot"] = "replace";
// m["closerequestfcn"] = make_fcn_handle ("closereq");
- m["colormap"] = colormap_property ();
m["visible"] = "on";
m["paperorientation"] = "portrait";
@@ -940,7 +933,8 @@
zdir ("normal"),
view (),
nextplot ("replace"),
- outerposition ()
+ outerposition (),
+ colormap ()
{
Matrix tlim (1, 2, 0.0);
tlim(1) = 1;
@@ -1130,6 +1124,8 @@
nextplot = val;
else if (name.compare ("outerposition"))
outerposition = val;
+ else if (name.compare ("colormap"))
+ colormap = colormap_property (val);
else
{
modified = false;
@@ -1279,6 +1275,7 @@
m.assign ("view", view);
m.assign ("nextplot", nextplot);
m.assign ("outerposition", outerposition);
+ m.assign ("colormap", colormap);
return m;
}
@@ -1404,6 +1401,8 @@
retval = nextplot;
else if (name.compare ("outerposition"))
retval = outerposition;
+ else if (name.compare ("colormap"))
+ retval = colormap;
else
warning ("get: invalid property `%s'", name.c_str ());
@@ -1507,6 +1506,8 @@
m["outerposition"] = touterposition;
+ m["colormap"] = colormap_property ();
+
return m;
}
diff -Pur octave-cvs/src/graphics.h octave-mod/src/graphics.h
--- octave-cvs/src/graphics.h 2007-06-15 13:40:56.000000000 -0500
+++ octave-mod/src/graphics.h 2007-06-19 16:11:52.000000000 -0500
@@ -1030,7 +1030,6 @@
OCTAVE_GRAPHICS_PROPERTY (octave_value, nextplot);
OCTAVE_GRAPHICS_PROPERTY (octave_value, closerequestfcn);
OCTAVE_GRAPHICS_PROPERTY (graphics_handle, currentaxes);
- OCTAVE_GRAPHICS_PROPERTY (colormap_property, colormap);
OCTAVE_GRAPHICS_PROPERTY (octave_value, visible);
OCTAVE_GRAPHICS_PROPERTY (octave_value, paperorientation);
@@ -1210,6 +1209,7 @@
OCTAVE_GRAPHICS_PROPERTY (octave_value, view);
OCTAVE_GRAPHICS_PROPERTY (octave_value, nextplot);
OCTAVE_GRAPHICS_PROPERTY (octave_value, outerposition);
+ OCTAVE_GRAPHICS_PROPERTY (colormap_property, colormap);
static std::string go_name;
};
- individual colormaps per subplots,
Daniel J Sebald <=