Heatmap

class visigoth.charts.heatmap.HeatMap(data, x=0, y=1, hue=None, width=512, height=512, x_order=None, y_order=None, hue_manager=None, stroke='black', stroke_width=2, font_height=12, text_attributes={}, value_formatter=None, display_values=False)

Create a HeatMap Chart

Parameters

data (dict) – A relational data set (for example, list of dicts/lists/tuples describing each row)

Keyword Arguments
  • x (str or int) – Identify the column to measure on the x-axis

  • y (str or int) – Identify the column to measure on the y-axis

  • hue (str or int) – Identify the column to define the hue

  • width (int) – the width of the plot in pixels

  • height (int) – the height of the plot in pixels

  • x_order (list) – list of the x-axis values to display in order

  • y_order (list) – list of the y-axis values to display in order

  • hue_manager (list) – a DiscreteHueManager|ContinuousHueManager object

  • stroke (str) – stroke color for bars

  • stroke_width (int) – stroke width for bars

  • font_height (int) – the height of the font for text labels

  • text_attributes (dict) – SVG attribute name value pairs to apply to text

  • value_formatter (visigoth.utils.ValueFormatter) – control the way values are represented

  • display_values (bool) – whether to display values in the chart

Note

x and y columns must be str or integer

Example

(Link to open example in new tab):

Source Code (Link to Github):

# -*- coding: utf-8 -*-

import random

from visigoth.diagram import Diagram
from visigoth.charts import HeatMap
from visigoth.containers import Box
from visigoth.utils import ContinuousHueManager
from visigoth.common.legend import ContinuousHueLegend

data = [{"c1":random.choice(["A","B","C","D","E","F"]),
         "c2":random.choice(["T","U","V","X","Y","Z"]),
         "v":random.random()} for i in range(25)]

d = Diagram()

hm = HeatMap(data,x="c1",y="c2",hue="v",width=400, height=400, hue_manager=ContinuousHueManager(hueMap=["white","red"]))
d.add(Box(hm))
legend = ContinuousHueLegend(hm.getHueManager(),400)
d.add(legend)

html = d.draw(format="html")
f = open("example.html", "w")
f.write(html)
f.close()