Mercurial > hg > octave-lyh
comparison scripts/plot/print.m @ 6179:235a1b456cf4
[project @ 2006-11-17 17:33:09 by jwe]
author | jwe |
---|---|
date | Fri, 17 Nov 2006 17:33:09 +0000 |
parents | 830235f4984f |
children | 44c91c5dfe1d |
comparison
equal
deleted
inserted
replaced
6178:830235f4984f | 6179:235a1b456cf4 |
---|---|
90 ## @var{size} is given in points. @var{fontname} is ignored for the | 90 ## @var{size} is given in points. @var{fontname} is ignored for the |
91 ## fig device. | 91 ## fig device. |
92 ## @end table | 92 ## @end table |
93 ## | 93 ## |
94 ## The filename and options can be given in any order. | 94 ## The filename and options can be given in any order. |
95 ## | |
96 ## @strong{Note}, the print function does not work with gnuplot's | |
97 ## muplitplot mode. This problem is a known bug, and it will be fixed | |
98 ## in a future version of Octave, but there is no simple fix (or it | |
99 ## would have been fixed long ago). You can work around the bug by | |
100 ## setting the terminal type and output yourself, then executing the | |
101 ## multiplot plotting commands. For example | |
102 ## | |
103 ## @example | |
104 ## @group | |
105 ## __gnuplot_set__ terminal postscript | |
106 ## __gnuplot_raw__ ("set output \"foo.ps\"\n"); | |
107 ## subplot (2, 1, 1); | |
108 ## sombrero (21); | |
109 ## subplot (2, 1, 2); | |
110 ## sombrero (41); | |
111 ## oneplot (); | |
112 ## __gnuplot_set__ terminal x11 | |
113 ## __gnuplot_raw__ ("set output\n"); | |
114 ## @end group | |
115 ## @end example | |
116 ## | |
117 ## will save both figures on a single page in the PostScript file | |
118 ## @file{foo.ps}. All labeling commands should appear before the plot | |
119 ## command for each subplot. | |
120 ## @end deftypefn | 95 ## @end deftypefn |
121 | 96 |
122 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | 97 ## Author: Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> |
123 ## Adapted-By: jwe | 98 ## Adapted-By: jwe |
124 | 99 |
216 endif | 191 endif |
217 dev = "epsc"; | 192 dev = "epsc"; |
218 name = strcat (tmpnam, ".eps"); | 193 name = strcat (tmpnam, ".eps"); |
219 endif | 194 endif |
220 | 195 |
221 unwind_protect | 196 if (strcmp (dev, "ps") || strcmp (dev, "ps2") ... |
222 | 197 || strcmp (dev, "psc") || strcmp (dev, "psc2") |
223 if (strcmp (dev, "ps") || strcmp (dev, "ps2") ... | 198 || strcmp (dev, "epsc") || strcmp (dev, "epsc2") |
224 || strcmp (dev, "psc") || strcmp (dev, "psc2") | 199 || strcmp (dev, "eps") || strcmp (dev, "eps2")) |
225 || strcmp (dev, "epsc") || strcmp (dev, "epsc2") | 200 ## Various postscript options |
226 || strcmp (dev, "eps") || strcmp (dev, "eps2")) | 201 if (dev(1) == "e") |
227 ## Various postscript options | 202 options = "eps "; |
228 if (dev(1) == "e") | 203 else |
229 options = "eps "; | 204 options = strcat (orientation, " "); |
205 endif | |
206 options = strcat (options, "enhanced "); | |
207 | |
208 if (any (dev == "c") || use_color > 0) | |
209 if (force_solid < 0) | |
210 options = strcat (options, "color dashed "); | |
230 else | 211 else |
231 options = strcat (orientation, " "); | 212 options = strcat (options, "color solid "); |
232 endif | 213 endif |
233 options = strcat (options, "enhanced "); | 214 else |
234 | 215 if (force_solid > 0) |
235 if (any (dev == "c") || use_color > 0) | 216 options = strcat (options, "mono solid "); |
236 if (force_solid < 0) | |
237 options = strcat (options, "color dashed "); | |
238 else | |
239 options = strcat (options, "color solid "); | |
240 endif | |
241 else | 217 else |
242 if (force_solid > 0) | 218 options = strcat (options, "mono dashed "); |
243 options = strcat (options, "mono solid "); | |
244 else | |
245 options = strcat (options, "mono dashed "); | |
246 endif | |
247 endif | 219 endif |
248 | 220 endif |
249 if (! isempty (font)) | 221 |
250 options = strcat (options, "\"", font, "\" "); | 222 if (! isempty (font)) |
251 endif | 223 options = strcat (options, "\"", font, "\" "); |
252 if (! isempty (fontsize)) | 224 endif |
253 options = strcat (options, " ", fontsize); | 225 if (! isempty (fontsize)) |
254 endif | 226 options = strcat (options, " ", fontsize); |
255 | 227 endif |
256 new_terminal = strcat ("postscript ", options); | 228 |
257 | 229 new_terminal = strcat ("postscript ", options); |
258 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) | 230 |
259 ## Adobe Illustrator, CorelDraw | 231 elseif (strcmp (dev, "aifm") || strcmp (dev, "corel")) |
260 if (use_color >= 0) | 232 ## Adobe Illustrator, CorelDraw |
261 options = " color"; | 233 if (use_color >= 0) |
262 else | 234 options = " color"; |
263 options = " mono"; | 235 else |
264 endif | 236 options = " mono"; |
265 if (! isempty (font)) | 237 endif |
266 options = strcat (options, " \"", font, "\""); | 238 if (! isempty (font)) |
267 endif | 239 options = strcat (options, " \"", font, "\""); |
268 if (! isempty (fontsize)) | 240 endif |
269 options = strcat (options, " ", fontsize); | 241 if (! isempty (fontsize)) |
270 endif | 242 options = strcat (options, " ", fontsize); |
271 | 243 endif |
272 new_terminal = strcat (dev, " ", options); | 244 |
273 | 245 new_terminal = strcat (dev, " ", options); |
274 elseif (strcmp (dev, "fig")) | 246 |
275 ## XFig | 247 elseif (strcmp (dev, "fig")) |
276 options = orientation; | 248 ## XFig |
277 if (use_color >= 0) | 249 options = orientation; |
278 options = " color"; | 250 if (use_color >= 0) |
279 else | 251 options = " color"; |
280 options = " mono"; | 252 else |
281 endif | 253 options = " mono"; |
282 if (! isempty (fontsize)) | 254 endif |
283 options = strcat (options, " fontsize ", fontsize); | 255 if (! isempty (fontsize)) |
284 endif | 256 options = strcat (options, " fontsize ", fontsize); |
285 | 257 endif |
286 new_terminal = strcat ("fig ", options); | 258 |
287 | 259 new_terminal = strcat ("fig ", options); |
288 elseif (strcmp (dev, "emf")) | 260 |
289 ## Enhanced Metafile format | 261 elseif (strcmp (dev, "emf")) |
290 options = " "; | 262 ## Enhanced Metafile format |
291 if (use_color >= 0) | 263 options = " "; |
292 options = " color"; | 264 if (use_color >= 0) |
293 else | 265 options = " color"; |
294 options = " mono"; | 266 else |
295 endif | 267 options = " mono"; |
296 if (force_solid >= 0) | 268 endif |
297 options = strcat (options, " solid"); | 269 if (force_solid >= 0) |
298 endif | 270 options = strcat (options, " solid"); |
299 if (! isempty (font)) | 271 endif |
300 options = strcat (options, " \"", font, "\""); | 272 if (! isempty (font)) |
301 endif | 273 options = strcat (options, " \"", font, "\""); |
302 if (! isempty (fontsize)) | 274 endif |
303 options = strcat (options, " ", fontsize); | 275 if (! isempty (fontsize)) |
304 endif | 276 options = strcat (options, " ", fontsize); |
305 | 277 endif |
306 new_terminal = strcat ("emf ", options); | 278 |
307 | 279 new_terminal = strcat ("emf ", options); |
308 elseif (strcmp (dev, "png") || strcmp (dev, "pbm")) | 280 |
309 ## Portable network graphics, PBMplus | 281 elseif (strcmp (dev, "png") || strcmp (dev, "pbm")) |
310 | 282 ## Portable network graphics, PBMplus |
311 ## FIXME -- New PNG interface takes color as "xRRGGBB" | 283 |
312 ## where x is the literal character 'x' and 'RRGGBB' are the red, | 284 ## FIXME -- New PNG interface takes color as "xRRGGBB" |
313 ## green and blue components in hex. For now we just ignore it | 285 ## where x is the literal character 'x' and 'RRGGBB' are the red, |
314 ## and use default. The png terminal now is so rich with options, | 286 ## green and blue components in hex. For now we just ignore it |
315 ## that one perhaps has to write a separate printpng.m function. | 287 ## and use default. The png terminal now is so rich with options, |
316 ## DAS | 288 ## that one perhaps has to write a separate printpng.m function. |
317 | 289 ## DAS |
318 ## if (use_color >= 0) | 290 |
319 ## eval (sprintf ("__gnuplot_set__ term %s color medium", dev)); | 291 ## if (use_color >= 0) |
320 ##else | 292 ## eval (sprintf ("__gnuplot_set__ term %s color medium", dev)); |
321 ##eval (sprintf ("__gnuplot_set__ term %s mono medium", dev)); | 293 ##else |
322 ##endif | 294 ##eval (sprintf ("__gnuplot_set__ term %s mono medium", dev)); |
323 | 295 ##endif |
324 new_terminal = "png large"; | 296 |
325 | 297 new_terminal = "png large"; |
326 elseif (strcmp (dev, "dxf") || strcmp (dev, "mf") || strcmp (dev, "hpgl")) | 298 |
327 ## AutoCad DXF, METAFONT, HPGL | 299 elseif (strcmp (dev, "dxf") || strcmp (dev, "mf") || strcmp (dev, "hpgl")) |
328 new_terminal = dev; | 300 ## AutoCad DXF, METAFONT, HPGL |
329 endif | 301 new_terminal = dev; |
330 | 302 endif |
331 __gnuplot_raw__ ("set terminal push;\n"); | 303 |
332 __gnuplot_raw__ (sprintf ("set terminal %s;\n", new_terminal)); | 304 __render_plot__ (new_terminal, name); |
333 | |
334 ## Gnuplot expects " around output file name | |
335 __gnuplot_raw__ (sprintf ("set output \"%s\";\n", name)); | |
336 | |
337 replot (); | |
338 | |
339 unwind_protect_cleanup | |
340 | |
341 __gnuplot_raw__ ("set terminal pop;\n"); | |
342 __gnuplot_raw__ ("set output;\n") | |
343 | |
344 replot (); | |
345 | |
346 end_unwind_protect | |
347 | 305 |
348 if (! isempty (convertname)) | 306 if (! isempty (convertname)) |
349 command = sprintf ("convert '%s' '%s'", name, convertname); | 307 command = sprintf ("convert '%s' '%s'", name, convertname); |
350 [errcode, output] = system (command); | 308 [errcode, output] = system (command); |
351 unlink (name); | 309 unlink (name); |