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)
else
display(heatmap(coalesce.(x,NaN)', color=:lightrainbow))
end
end
ds = Dataset("/home/abarth/Data/DivaData/Global/gebco_30sec_16.nc");
bathymetry = ds["bat"][:,:] # returns a Array{Union{Missing, Float32},2}
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.
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.
This really seems like the minimum time to first plot after UnicodePlots! GR doesn’t appear to have a spy() for sparse matrices. I put this together quickly to plot sparsity patterns in iTerm2 and it’s great:
This could be a great alias for show() for sparse matrices in terminals that support it.
However, I’m not finding a convenient reference for keyword arguments accepted by GR. How do I
I would like to be able to set an environment variable that makes the sixel terminal display default for all plotting packages, so that when I load any plotting package I don’t need to configure.
That would require loading a plotting package each time I launch Julia, which I definitely don’t want in my startup file.
Currently, enabling sixel requires setting an option after loading the package.
The point of having an environment variable is to pre-set the option before any plotting package is loaded, so that I can choose to load plotting whenever I need it, without worrying about enabling sixel.
This is an old thread but if some desperate soul is still looking for a solution I want to share my accidental discovery:
How to plot inside iTerm on macOS
This produces sharp plots even on Retina displays. Adjust the size and scaling to your liking.
using Plots
theme(:dark) # for dark terminal backgrounds
default(display_type=:inline, size=(1500,800), thickness_scaling=1.5)
plot(rand(20))
(Minor) caveats:
- The GKS QT terminal starts in the background (it doesn't open a window).
- You can even ssh into a headless remote machine and initiate the plot there. Some QT related error messages do appear though.
Set the the environment variable GKSwstype=nul before starting julia to suppress the launching of gksqt.
You can even ssh into a headless remote machine and initiate the plot there.