Created
January 18, 2014 08:54
-
-
Save natj/8487922 to your computer and use it in GitHub Desktop.
Small and crude colorbar implementation to Winston
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. I've used a version of your code here EEG.jl commit