Difference between revisions of "Debug plotting issues"

From Octave
Jump to navigation Jump to search
m (maint: fix external link syntax, use https)
 
Line 5: Line 5:
 
== Basics ==
 
== Basics ==
  
* '''Octave version:''' Execute 'ver' in Octave and copy "GNU Octave Version" and "Operating System" verbatim. If you are on Windows please mention which build (MinGW, Cygwin, MXE, Visual Studio see [[Octave for Microsoft Windows]]) and where you got it (download from http://sourceforge.net/, http://mxeoctave.osuv.de/) or have you build it yourself?. This is important because some packages includes whole build environment while other just provide binaries even for octave-forge packages.
+
* '''Octave version:''' Execute 'ver' in Octave and copy "GNU Octave Version" and "Operating System" verbatim. If you are on Windows please mention which build (MinGW, Cygwin, MXE, Visual Studio see [[Octave for Microsoft Windows]]) and where you got it (download from https://sourceforge.net/, http://mxeoctave.osuv.de/) or have you build it yourself?. This is important because some packages includes whole build environment while other just provide binaries even for octave-forge packages.
  
 
* '''Operating system:'''
 
* '''Operating system:'''
Line 81: Line 81:
 
paperposition, papersize and so on are ignored in this case.
 
paperposition, papersize and so on are ignored in this case.
  
This uses [http://geuz.org/gl2ps/| GL2PS_BSP_SORT], [http://en.wikipedia.org/wiki/Binary_space_partitioning| BSP on wikipedia]
+
This uses [http://geuz.org/gl2ps/ GL2PS_BSP_SORT], [https://en.wikipedia.org/wiki/Binary_space_partitioning BSP on Wikipedia]
 
   drawnow ("eps", "cat > out.eps")
 
   drawnow ("eps", "cat > out.eps")
  

Latest revision as of 13:04, 2 February 2018

THIS PAGE IS A STUB

This page should help with debugging plotting and printing issues and to collect important information which should be included into bugreports or when asking on the mailinglist.

Basics[edit]

  • Octave version: Execute 'ver' in Octave and copy "GNU Octave Version" and "Operating System" verbatim. If you are on Windows please mention which build (MinGW, Cygwin, MXE, Visual Studio see Octave for Microsoft Windows) and where you got it (download from https://sourceforge.net/, http://mxeoctave.osuv.de/) or have you build it yourself?. This is important because some packages includes whole build environment while other just provide binaries even for octave-forge packages.
  • Operating system:
    • Windows: Is it XP 32bit or 64bit? Windows 7 or 8?
    • GNU/Linux: Have you installed Octave using your package system (apt-get, yum..) or compiled from source tarball?
  • If you get a warning on startup, for example "warning: function xyz.m shadows a built-in function" please copy it verbatim
  • If you get an error message, please, please, please copy the message verbatim

I can't plot or print or the output doesn't look as expected[edit]

Please create a simple, as small as possible example which shows the problem so others can reproduce the problem on their system and help you. Upload a screenshot (together with the script) if you can't describe it with words.

  • Sometimes the figure on the screen visually differs from the file generated with "print". If this is the case please mention this and consider adding a screenshot of the figure window together with the generated print.
  • Which toolkit are you using? Common toolkits are 'fltk' (which is default now) or 'gnuplot'. Consider switching to another available toolkit (see available_graphics_toolkits) and try it there. You have to execute (for example switch to gnuplot) 'graphics_toolkit gnuplot' before any plotting command.

Debug printing with gnuplot[edit]

Try

 print("testplot.eps", "-debug")

and attach the generated octave-print-commands.log, debug message and testplot.eps.

Debug printing with fltk[edit]

The output of commands described here were created with a GNU/Linux system. Windows or MacOS builds may differ. Please update the article if you find any differences.

The class opengl_renderer is used to render a graphics_object to an OpenGL context. If you use the "print" command with graphics_toolkit fltk, gl2ps is used to capture these OpenGL drawing commands and translates them to Encapsulated PostScript (EPS). If you have requested a different output format than EPS, the EPS output of gl2ps is then piped to ghostscript (gs) which does the conversion to PDF, PNG, JPG ...

You can see the pipleline to ghostscript by adding "-debug" to the "print" command:

Code: print with "-debug"
octave:1> sombrero
octave:2> print("-dpng", "out.png", "-debug")
Ghostscript command: '/usr/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150x150 -dEPSCrop -sOutputFile="out.png" -'
fltk-pipeline: '/usr/bin/gs -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150x150 -dEPSCrop -sOutputFile="out.png" -'

For debugging purposes it may be desired to have the direct output of gl2ps without piping them through ghostscript.

This can simply be done with

 print -depsc out.eps

or if you prefer a black/white output:

 print -deps out.eps

If you want to wiretap the output of gl2ps, which is meant to go to ghostscript if printing a PNG, JPG etc. it's a little bit more complicated because the existence of the ghostscript binary is checked first. Therefore simply replacing the ghostscript binary

 print -dpng "-Gcat > debug.eps" out.eps

won't work. A hack is to create a shell script (myredirect.sh in my case ) which does the redirection:

 #!/bin/bash
 rm debug.eps
 while read x ; do echo $x >> debug.eps ; done

Which can then be used with

 print -dpng "-G./myredirect.sh" out.eps

Another way is to directly use the opengl_renderer to draw to gl2ps. paperposition, papersize and so on are ignored in this case.

This uses GL2PS_BSP_SORT, BSP on Wikipedia

 drawnow ("eps", "cat > out.eps")

For 2D plots a simpler algorithm(GL2PS_SIMPLE_SORT) is choosen but you can force this also for 3D plots:

 drawnow ("epsis2d", "cat > out.eps")

some Windows issues[edit]

known bugs[edit]

Please see also the FAQ

  • A common problem is that printing with fltk only works if the figure is visible, see [1]

Test scripts[edit]

Code: FLTK printing test script
close all
graphics_toolkit fltk
h = plot ([0, 0.5, 1], [0, 0.5, 1], '-sb');
set (h, 'markerfacecolor', 'b', 'markersize', 20, 'linewidth', 4)
hold all
h = plot ([1, 0.5, 0], [0, 0.5, 1], '-or');
set (h, 'markerfacecolor', 'r', 'markersize', 20, 'linewidth', 4)
set (gca (), 'color', 'c')
title ('Cyan background, black axes. A red line with circle markers above a blue line with square markers.')
print -depsc junk1.eps

# Bug 35648, is this a representive test for this? What is the desired output?
close all
hp = patch([1 1 2 2],[1 2 2 1], [1 0.8 1]);
grid on;
set(gca,'layer','bottom');
title ('Please describe what we should see')
print -depsc junk2.eps