1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 - INRIA - Pierre MARECHAL
3 // Copyright (C) 2016 - Scilab Enterprises - Paul Bignier
4 // Copyright (C) 2017 - Samuel GOUGEON
6 // This file is released under the 3-clause BSD license. See COPYING-BSD.
11 function demo_colormaps()
14 // =========================================================================
16 frame_w = 150; // Frame width
17 frame_h = 330; // Frame height
19 plot_w = 600; // Plot width
20 plot_h = 550; // Plot height
22 margin_x = 15; // Horizontal margin between each elements
23 margin_y = 15; // Vertical margin between each elements
25 defaultfont = "arial"; // Default Font
26 text_font_size = 12; // Text font size
29 // =========================================================================
31 axes_w = 3*margin_x + frame_w + plot_w; // axes width
32 axes_h = 2*margin_y + max(frame_h,plot_h); // axes height
34 fig_handle = figure( ...
35 "infobar_visible", "off", ...
36 "toolbar_visible", "off", ...
37 "toolbar", "none", ...
38 "default_axes", "on", ...
39 "layout", "gridbag", ...
42 "figure_position", [0 0], ...
43 "axes_size", [axes_w axes_h], ...
44 "figure_name", _("Misc"));
46 c = createConstraints("gridbag", [2 1 1 1], [1 1], "vertical", "right");
47 // Create an empty panel on the right to occupy the 3/4 of the screen (figure plot)
48 empty_frame = uicontrol(fig_handle, "style", "frame","constraints", c);
50 c = createConstraints("gridbag", [1 1 1 5], [0 1], "both", "left", [0 0], [90 0]);
51 u = uicontrol(fig_handle, ...
53 "backgroundcolor", [1 1 1], ...
54 "layout", "border", ...
57 // Add top and bottom empty panels to pad the upcoming colormap panel
58 c = createConstraints("border", "top", [0 80]);
59 top = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c);
60 c = createConstraints("border", "bottom", [0 80]);
61 bottom = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c);
63 // Border for the colormap frame
64 b_f_colormap = createBorderFont("", 15);
65 b_l_colormap = createBorder("line", "navy", 2);
66 b_colormap = createBorder("titled", b_l_colormap, "Colormap", "center", "top", b_f_colormap, "navy");
68 colormap_frame = uicontrol(u, ...
70 "backgroundcolor", [1 1 1], ...
71 "border", b_colormap, ...
72 "layout", "gridbag", ...
73 "tag", "colormap_frame");
75 demo_viewCode("colormaps.dem.sce");
77 fig_handle.color_map = jetcolormap(128);
80 // =========================================================================
81 colormaps = ["Jet" "Parula" "HSV" "Hot" "Gray" ..
82 "Winter" "Spring" "Summer" "Autumn" ..
83 "Bone" "Copper" "Pink" "Rainbow" "Ocean" "White"];
84 for i = 1:size(colormaps,"*")
85 mapname = colormaps(i);
86 c = createConstraints("gridbag", [1 i 1 1], [1 1], "both", "upper");
87 disk_radio = uicontrol( ...
88 "parent" , colormap_frame, ...
89 "style" , "radiobutton", ...
90 "string" , mapname, ...
91 "fontname" , defaultfont, ...
92 "fontunits" , "points", ...
93 "fontsize" , text_font_size, ...
94 "value" , 1*(i==1), ...
95 "background" , [1 1 1], ...
96 "callback" , "demo_update_misc", ...
97 "groupname" , "colormap_demo", ..
98 "constraints" , c, ...
99 "tag" , mapname+"colormap_radio");
103 // =========================================================================
107 my_plot_region_pos_x = ((2*margin_x+frame_w)/axes_w);
108 my_plot_region_pos_y = 0;
109 my_plot_region_w = 1-my_plot_region_pos_x;
110 my_plot_region_h = 1;
112 // First plot : grayplot(); top - left
114 my_plot_1_axes = newaxes();
115 my_plot_1_pos_x = ((2*margin_x+frame_w)/axes_w);
116 my_plot_1_pos_y = 0.05;
117 my_plot_1_w = (1-my_plot_region_pos_x)/2.3;
119 my_plot_1_axes.axes_bounds = [ my_plot_1_pos_x my_plot_1_pos_y my_plot_1_w my_plot_1_h ];
121 my_plot_1_axes.tight_limits = "on";
122 e = my_plot_1_axes.children(1);
124 e.data.z(1,1) = min(z)+(max(z)-min(z))/127*128;
126 // Second plot : plot3d1(); top right
128 my_plot_2_axes = newaxes();
129 // my_plot_2_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2;
130 my_plot_2_pos_x = my_plot_1_pos_x + my_plot_1_w;
132 my_plot_2_w = (1-my_plot_region_pos_x)/2 + 0.03;
134 my_plot_2_axes.axes_bounds = [ my_plot_2_pos_x my_plot_2_pos_y my_plot_2_w my_plot_2_h ];
136 my_plot_2_axes.rotation_angles = [80 45];
138 // Third plot : grayplot(); bottom - left
140 my_plot_3_axes = newaxes();
141 my_plot_3_pos_x = ((2*margin_x+frame_w)/axes_w);
142 my_plot_3_pos_y = 1/2;
143 my_plot_3_w = (1-my_plot_region_pos_x)/2;
145 my_plot_3_axes.axes_bounds = [ my_plot_3_pos_x my_plot_3_pos_y my_plot_3_w my_plot_3_h ];
148 my_plot_3_axes.axes_bounds(3:4) = [0.33 0.45];
149 xtitle("Matplot","","")
151 // Fourth plot : knot(); bottom - right
153 my_plot_4_axes = newaxes();
154 // my_plot_4_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2;
155 my_plot_4_pos_x = my_plot_3_pos_x + my_plot_3_w - 0.05;
156 my_plot_4_pos_y = 1/2;
159 my_plot_4_axes.axes_bounds = [ my_plot_4_pos_x my_plot_4_pos_y my_plot_4_w my_plot_4_h ];
161 deff("[x,y,z] = knot(u,v)",..
164 "x = (5.*cos(u)+cos(u).*cos(v))";
165 "y = (5.*sin(u)+sin(u).*cos(v))";
166 "z = (uu.*sin(v))";])
173 [xx,yy,zz]=eval3dp(knot,2*%pi*Nx,2*%pi*Ny);
179 kk1=modulo(kk1,60)*2;
181 KKK=list(ZZZ,[kk1 kk2]);
182 plot3d(XXX,YYY,KKK,35,70," @ @ ",[2,1,4],[-6,6,-6,6,-6,6]);
186 f.color_map = jetcolormap(128);
188 my_plot_2_axes.background = color(240,240,240);
189 my_plot_4_axes.background = color(240,240,240);
192 colorbar(0,128, [0 128], "%d");
193 gcf().children(1).axes_bounds = [0.14 0.1 0.1 0.8];
194 gcf().figure_name = "Jetcolormap";
197 fig_handle.visible = "on";
201 function demo_update_misc()
203 my_figure.immediate_drawing = "off";
204 set(gcbo, "value", 1);
205 colormap_name = strtok(get(gcbo,"tag"),"_");
206 execstr(["my_figure.color_map = "+convstr(colormap_name,'l')+"(128);"
207 "my_figure.figure_name = """+colormap_name+""""]);
209 // Gray background for 3d axes
210 for i = 1:size(my_figure.children,"*"),
211 child = my_figure.children(i);
212 if child.type=="Axes" then
213 if child.view=="3d" then
214 child.background = color(240,240,240);
220 my_figure.immediate_drawing = "on";
225 clear demo_colormaps;