Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Something has come up which demands me to work only in command line. My primary job is programming (mostly in Fortran and Octave) and I need to display plots.

As a lame example:

I open octave and type ezplot('sin(x)') and it outputs that X11 Display Environment not set and unable to open display. Is there any way for me to view graphics in TTY?

Obviously, I don't expect awesome graphics but I need to see if I am on the right track once a while.

My current algorithm is extremely inefficient. I print -djpeg foo.jpeg and then scp it to my neighboring computer. Borrow that and continue.

share|improve this question
    
Three obvious questions spring to mind: what OS are you running on your desktop machine? Are you on the system console, or connected remotely? And, if connected remotely, what protocol/software do you use to connect to the remote machine (e.g. SSH using PuTTY)? –  Alexios Jan 24 '12 at 19:51
1  
You actually have two different questions here. Is there any way for me to view graphics in TTY? (answer: aalib or svgalib); and the unstated How can I print graphs to ASCII? (gnuplot, cernlib, etc). Can you clarify what you want rather than how you expect to achieve it? –  dmckee Jan 24 '12 at 20:20
2  
Related to and may be answered in Any (text based) plotting tools in unix toolbox?. –  dmckee Jan 24 '12 at 20:20
    
A quick google suggests that octave does not support aalib directly and no one cares, there are signs that some people want it to work with svgalib, though I don't know if it actually works. –  dmckee Jan 24 '12 at 20:24

6 Answers 6

up vote 3 down vote accepted

If you simply have a series of .jpeg images that you wish to display in a tty, you can use aview or asciiview. When calling asciiview with an image, it will convert the image to the .pnm format - using an external program like NetPBM or ImageMagic - before passing it to aview for displaying. The .pnm is the ascii image format used to represent the image as set of characters. To view an image in this format, simply use:

$ asciiview foo.jpeg

or to save a .pnm copy first:

$ convert foo.jpeg foo.pnm
$ aview foo.pnm

These support the driver from aalib.

share|improve this answer
    
None of the other methods word. –  user14517 Jan 25 '12 at 13:39

Can you not run an X server on another tty and switch to it when you need to? If you have a machine next to you that is running X, then you can use X11 forwarding to have it display there.

share|improve this answer
    
An example of this can be found in this question. –  Emanuel Berg Oct 16 '12 at 22:39

The most direct answer is to use jp2a : JPEG to ASCII.

Maybe you can use the famous ascii-art library : libcaca. It even allows to see movie in a terminal, so it should also works for simple jpeg.

share|improve this answer

You can directly draw graphs as ASCII with gnuplot;
Set the terminal type to dumb, that's all you need:

$ gnuplot
gnuplot> set terminal dumb
Terminal type set to 'dumb'
Options are 'feed  size 79, 24'
gnuplot> plot sin(x)



    1 ++---------------***---------------+---**-----------+--------**-----++
      +                *  *              +  *  **         +  sin(x) ****** +
  0.8 ++              *   *                 *    *               *    *   ++
      |              *     *               *     *               *     *   |
  0.6 *+             *      *              *     *               *     *  ++
      |*             *      *             *       *             *       *  |
  0.4 +*            *       *             *       *             *       * ++
      |*            *        *            *        *           *        *  |
  0.2 +*           *         *            *        *           *         *++
    0 ++*          *          *          *         *          *          *++
      | *          *          *         *           *         *           *|
 -0.2 ++ *         *          *         *           *         *           *+
      |  *        *           *        *             *        *           *|
 -0.4 ++ *        *            *       *             *       *            *+
      |  *       *              *      *             *      *              *
 -0.6 ++  *      *              *      *             *      *             +*
      |    *    *               *     *               *     *              |
 -0.8 ++   *    *                *   *                 *   *              ++
      +     *  *       +         **  *   +             *  *                +
   -1 ++-----**--------+-----------**----+--------------***---------------++
     -10              -5                 0                5                10

gnuplot>
share|improve this answer
1  
Not related to OP but I note it also has the canvas terminal, which is great! –  Amphiteóth Nov 27 at 0:32
    
@Amphiteóth Yes, that one is interesting too - it's rendering to a HTML canvas, right? I would have mentioned it if the links and elinks text mode browser could render it. –  Volker Siegel Nov 27 at 0:36
1  
Yes, with sth like set output 'output.html' you get that file, and looking at the source, it's like inline JS and calls canvastext.js and gnuplot_common.js. Didn't know this! Quite useful! –  Amphiteóth Nov 27 at 0:52

For actual graphics your best (and possibly only) bet is svgalib, but be aware that it has nothing in common with X11, so you'll need to write your own replacement for ezplot.

share|improve this answer

If you are on a console TTY on Linux or FreeBSD, you can use svgalib to show images in graphics mode, without X11. The library can switch the console to graphics mode - it's just not commonly used today, because X11 has it's advantages.

There is an image viewer for the console, which may need some tweaks to build it because it's somewhat outdated, but it's worth trying.

The image viewer zgv - there is also a similar viewer for X11, named xzgv, in case you grow to like the interface very much.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.