Skip to content

Instantly share code, notes, and snippets.

@natj
Created January 18, 2014 08:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natj/8487922 to your computer and use it in GitHub Desktop.
Save natj/8487922 to your computer and use it in GitHub Desktop.
Small and crude colorbar implementation to Winston
#colorbar
function colorbar(dmin, dmax; orientation="horizontal", colormap=_default_colormap, kvs...)
if orientation == "vertical"
p=FramedPlot(aspect_ratio=10.0)
setattr(p.x, draw_ticks=false)
setattr(p.y1, draw_ticks=false)
setattr(p.x1, draw_ticklabels=false)
setattr(p.y1, draw_ticklabels=false)
setattr(p.y2, draw_ticklabels=true)
xr=(1,2)
yr=(dmin,dmax)
y=linspace(dmin, dmax, 256)*1.0
data=[y y]
elseif orientation == "horizontal"
p=FramedPlot(aspect_ratio=0.1)
setattr(p.y, draw_ticks=false)
setattr(p.x1, draw_ticks=false)
setattr(p.y1, draw_ticklabels=false)
setattr(p.x1, draw_ticklabels=false)
setattr(p.x2, draw_ticklabels=true)
yr=(1,2)
xr=(dmin, dmax)
x=linspace(dmin,dmax,256)*1.0
data=[x', x']
end
setattr(p, :xrange, xr)
setattr(p, :yrange, yr)
setattr(p; kvs...)
clims = (minimum(data),maximum(data))
img = data2rgb(data, clims, colormap)
add(p, Image(xr, yr, img))
p
end
@rob-luke
Copy link

rob-luke commented May 7, 2015

Thanks. I've used a version of your code here EEG.jl commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment