Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose continuous analogues of colormaps #69

Open
jwmerrill opened this issue Oct 20, 2014 · 1 comment
Open

Expose continuous analogues of colormaps #69

jwmerrill opened this issue Oct 20, 2014 · 1 comment

Comments

@jwmerrill
Copy link
Contributor

It's currently easy to get a beautiful red-blue diverging colormap with, e.g. 20 colors by calling

colormap("RdBu", 20)

I would like to be able to map a continuous variable (for definiteness, say it ranges from -1.0 to 1.0) into this map, but I don't currently see an easy way to do this. Basically what I'm asking for is the N → ∞ limit of

function (x)
    colormap("RdBu", N)[1 + ifloor((x + 1.0)/2.0*N)]
end

I haven't gotten completely to the bottom of the way things are currently implemented, but given that you can already specify different values for N, it seems like something close to such a function must already exist privately somewhere inside the implementation, and it would be nice to expose it.

@natj
Copy link
Contributor

natj commented Dec 1, 2014

Under the hood colormaps are just Bezier splines in LCHuv colorspace from one color to other so what you are asking is completely possible. Instead of using the colormap function that splices the continuous representation into parts, you can use the underlying functions and call the splines directly with what ever value you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants