Plots in the terminal (with sixel)


I just came across “sixel” which allows to show graphics in the terminal (while reading this )

Unfortunately, gnome-terminal does not support this (, but xterm (run as xterm -ti vt340) does.

In fact it does not take much to use this with julia and PyPlot (or any other plotting package), just the convert tool from ImageMagic.

I started Julia with unset DISPLAY (on Linux)

using PyPlot"dark_background")
function show()
   fname = tempname() * ".png";
   run(`convert $fname -geometry 800x480  sixel:-`)
   return nothing
x = 1:0.1:10;
pcolor(sin.(x) * sin.(x)');

Off-topic, but also useful is lsix: “ls” for images (


You could also try the unregistered It uses ImageMagick.


SixelTerm.jl is really nice! Thanks for sharing! It is quite impressive what you can do with 30 lines of code in SixelTerm.jl.

1 Like

GR has builtin sixel support:

using GR

Could also be integrated into Plots gr() backend - just let me know …


It could also be useful to overload the display function to make a plot for long vector and a heatmap for large matrices. I think I will use the feature at lot more!

ENV["GKSwstype"] = "nul"    # needed for the GR backend on headless servers
using Plots
using SixelTerm
using NCDatasets

function Base.display(x::Matrix{T}) where T <: Union{Number,Union{Missing,Number}}
    if length(x) < 300
        invoke(display, Tuple{AbstractMatrix}, x)
        display(heatmap(coalesce.(x,NaN)', color=:lightrainbow))

ds = Dataset("/home/abarth/Data/DivaData/Global/");
bathymetry = ds["bat"][:,:] # returns a Array{Union{Missing, Float32},2}


… no need to overload display in GR: :grinning:


Not in the REPL but I still prefer

using GMT
grdimage("@earth_relief_05m.grd", proj=:Winkel, fmt=:png, show=true)


But if I see that correctly, this means, that GR.jl can only plot using terminals that are hard coded in GR.jl, right`


I ran into some pages in Japanese when looking for the details of the sixel generation algorithm so I cannot judge how complex it is, but I am wondering if it would make sense to have a native Julia implementation. It would have obvious advantages for all packages using this functionality, and could also serve as a nice reference.


GR.jl is only a wrapper for the GR framework. Any software that uses GR.jl can produce sixel graphics. It’s just about converting an internally rendered image to sixels …

Thus, it can be used from Julia, Python C, or whatever.


The latest release of Gaston also supports sixel:

I had had experimental support for a while, but this thread motivated me to finish it up. Also, since gnuplot has native sixel support, no external libraries or converters are needed.