Debug plotting issues: Difference between revisions

From Octave
Jump to navigation Jump to search
(create test script stub)
m (maint: fix external link syntax, use https)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
== Basics ==
== Basics ==


* '''Octave version:''' Execute 'ver' in Octave and copy the first 5 lines verbatim. If you are on Windows please mention which build (MinGW, Cygwin, MXE, Visual Studio see http://wiki.octave.org/Octave_for_Microsoft_Windows) and where you got it (download from http://sourceforge.net/, http://mxeoctave.osuv.de/ or have you build it yourself?).
* '''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 13: Line 13:
* 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 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 copy the message 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 ==
== I can't plot or print or the output doesn't look as expected ==
Line 22: Line 22:
* 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.
* 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? Execute 'graphics_toolkit' in octave to query it. Common toolkits are 'fltk' 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.
* 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.


* Which Ghostscript version? Is it a 32 or 64bit build? Please add URL to download. If 64bit under Windows see http://wiki.octave.org/Octave_for_Microsoft_Windows#Printing_.28installing_Ghostscript.29
* Which Ghostscript version do you use? Is it a 32 or 64bit build? Please add URL to download. If 64bit under Windows see [[Octave for Microsoft Windows#Printing (installing Ghostscript)]]
    
    
=== printing with gnuplot ===
=== Debug printing with gnuplot ===


Try
Try
Line 32: Line 32:
and attach the generated octave-print-commands.log, debug message and testplot.eps.
and attach the generated octave-print-commands.log, debug message and testplot.eps.


=== printing with fltk ===
=== Debug printing with fltk ===


A common problem is that printing with fltk only works if the figure is visible, see [http://savannah.gnu.org/bugs/?33180]
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"|<syntaxhighlight lang="octave" style="font-size:13px">
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" -'
</syntaxhighlight>}}
 
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 [http://geuz.org/gl2ps/ GL2PS_BSP_SORT], [https://en.wikipedia.org/wiki/Binary_space_partitioning 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 ==
== some Windows issues ==
Line 40: Line 91:
* A user had problems printing with fltk in windows. After he updated the graphic drivers the problem was gone. http://octave.1599824.n4.nabble.com/Problem-with-Print-under-Octave-3-8-1-under-windows-tp4664755.html
* A user had problems printing with fltk in windows. After he updated the graphic drivers the problem was gone. http://octave.1599824.n4.nabble.com/Problem-with-Print-under-Octave-3-8-1-under-windows-tp4664755.html


== Test script ==
== known bugs ==
 
Please see also the [[FAQ]]
 
* A common problem is that printing with fltk only works if the figure is visible, see [http://savannah.gnu.org/bugs/?33180]
 
== Test scripts ==


{{Code|FLTK printing test script|<syntaxhighlight lang="octave" style="font-size:13px">
{{Code|FLTK printing test script|<syntaxhighlight lang="octave" style="font-size:13px">
Line 61: Line 118:
title ('Please describe what we should see')
title ('Please describe what we should see')
print -depsc junk2.eps
print -depsc junk2.eps
 
</syntaxhighlight>}}
}}

Latest revision as of 21: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