Editing Debug plotting issues

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
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 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.
* '''Octave version:''' Execute 'ver' in Octave and copy it verbatim. If you are on Windows mention which build (MinGW, Cygwin, MXE, Visual Studio see http://wiki.octave.org/Octave_for_Microsoft_Windows) and where did you get it?


* '''Operating system:'''
* '''Operating system:'''
** Windows: Is it XP 32bit or 64bit? Windows 7 or 8?
** 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?
** GNU/Linux: Have you installed Octave using your package system (apt-get, yum..) or via 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 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'''
* '''If you get an error message, 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 20: Line 20:
on their system and help you. Upload a screenshot (together with the script) if you can't describe it with words.
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? 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)]]
    
    
=== Debug printing with gnuplot ===
=== printing with gnuplot ===


Try
Try
   print("testplot.eps", "-debug")
   print("testplot.eps", "-debug")
and attach the generated octave-print-commands.log, debug message and testplot.eps.
and attach the generated octave-print-commands.log and debug message.
 
=== Debug printing with fltk ===
 
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 ==
 
* 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
 
== 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">
=== printing with fltk ===
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?
A common problem is that printing with fltk only works if the figure is visible, see [http://savannah.gnu.org/bugs/?33180]
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
</syntaxhighlight>}}
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: