# Heatmaps in Ruby

**URL:** <https://www.ruby-forum.com/t/heatmaps-in-ruby/179508>\
**Category:** Ruby\
**Created:** [November 26, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508 "2009-11-26T14:42:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lasastard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/58956e/32.png) [@lasastard](https://www.ruby-forum.com/u/lasastard)\
**Post date:** [November 26, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508/1 "2009-11-26T14:42:35Z")

</div>

Hi,

I am currently thinking about doing a heatmap for data visualization,  
but I have very little experience with any type of graphical tools in  
ruby (like the various SVG libs etc).

So I was hoping someone could point me in the right direction and save  
me some time trying out useless libraries 😉 Doesn’t have to be ruby  
either, but that way I could probably integrate it more easily into my  
analysis pipeline.

Thanks,

Marc

---

<div class="post-metadata">

**Author:** ![lasastard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/58956e/32.png) [@lasastard](https://www.ruby-forum.com/u/lasastard)\
**Post date:** [November 27, 2009, 12:32am UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508/2 "2009-11-27T00:32:43Z")

</div>

On Thu, Nov 26, 2009 at 8:43 AM, Marc H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

[http://blog.revolution-computing.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html](http://blog.revolution-computing.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html)

I think there are ruby bindings for R too, so that may help.

Best regards,  
Michael G.

---

<div class="post-metadata">

**Author:** ![lasastard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/58956e/32.png) [@lasastard](https://www.ruby-forum.com/u/lasastard)\
**Post date:** [November 27, 2009, 1:49pm UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508/3 "2009-11-27T13:49:55Z")

</div>

Hi,

thanks for the link - I suspected that R would probably have that  
functionality. At this point I am simply curious how to do it in ruby.

I managed to write a simple program that uses RMagick to draw an  
intensity map. It takes the highest observed value, sets it to 100% and  
then draws other values in relation to that.

What I don’t know is how to write a method that, based on a numerical  
value, determines a color, i.e. from blue to red.

So if for example the value ‘1’ should be a deep blue and ‘100’ a bright  
red - how would one do that? All color coding schemes allowed!

RMagick can draw colors using a cmyk notation (c,m,y,k) in percent as  
well as rgb or the commonly found code in css files ala #00cc33 .

Am interested in all suggestions 😉

---

<div class="post-metadata">

**Author:** ![lasastard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/58956e/32.png) [@lasastard](https://www.ruby-forum.com/u/lasastard)\
**Post date:** [November 27, 2009, 6:55pm UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508/4 "2009-11-27T18:55:20Z")

</div>

On Fri, Nov 27, 2009 at 13:49, Marc H.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What I don’t know is how to write a method that, based on a numerical  
> value, determines a color, i.e. from blue to red.
> 
> So if for example the value ‘1’ should be a deep blue and ‘100’ a bright  
> red - how would one do that? All color coding schemes allowed!

Hi,

what you are looking for is “color ramp” or “color gradient”, there  
are many sites with algorithms  
how to compute colors between two or more given ones (for example from  
blue to red).

J.

---

<div class="post-metadata">

**Author:** ![lasastard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/58956e/32.png) [@lasastard](https://www.ruby-forum.com/u/lasastard)\
**Post date:** [November 27, 2009, 10:04pm UTC](https://www.ruby-forum.com/t/heatmaps-in-ruby/179508/5 "2009-11-27T22:04:22Z")

</div>

Hello,

> Am interested in all suggestions 😉

You could be interested in Tioga which can do exactly what you are  
looking for. See the many examples given in the tutorial.

[http://www.itp.ucsb.edu/~paxton/tioga.html](http://www.itp.ucsb.edu/~paxton/tioga.html)

Cheers,
