Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom colorgradient heatmap in Julia

Tags:

julia

plots.jl

I am currently using the Plots package and have it along with the PyPlot packages installed. With the code

using Plots
y = rand(10, 10)
pyplot()
plt = plot(y, st=:heatmap, clim=(0,1), color=:coolwarm, colorbar_title="y")

I am able to produce this heat map

My question is how I can change the color gradient from its current setting (coolwarm which corresponds with a transition from red to gray to blue) to a new setting which has a gradient from red to green to blue. Is there some way to create a custom colorgradient and use that as an argument where I have 'coolwarm' in my sample code?

like image 567
JBar Avatar asked May 25 '17 20:05

JBar


1 Answers

Yes. First of all there are numerous color libraries in Plots. Try clibraries(), then e.g. cgradients(:colorbrewer) or showlibrary(colorbrewer). In addition, you can make your own gradient with e.g. cgrad([:red, :green, :blue]) and pass that as the color argument.

like image 195
Michael K. Borregaard Avatar answered Nov 13 '22 07:11

Michael K. Borregaard