1

I am looking for suggestions as how to create plots similar to GitHub punch cards with JFreeChart. E.g.

enter image description here

I guess it's some variant of a heat map, or two dimensional histogram.

0__
  • 66,707
  • 21
  • 171
  • 266

2 Answers2

2

Ok, so I found XYBubbleRenderer which looks like a good starting point.

  • create a MatrixSeries with rows = 7, columns = 24
  • fill in the frequencies accordingly. I found it useful to normalise the values first to 0...1, then take the square root (smaller values have a bit better visible circles), then multiply by 0.5 (otherwise the circles are too large)
  • create a MatrixSeriesCollection from that
  • use ChartFactory.createBubbleChart
  • the circle outline can only be removed via plot.getRenderer.setSeriesOutlinePaint(0, new Color(0, 0, 0, 0))
  • ensure integer tick units on both axis
  • x-axis range -0.5 to 23.5, y-axis range -0.5 to 6.5 (or 0.5 to 7.5 if you use Calendar.DAY_OF_WEEK)
  • custom NumberTickUnit for the y-axis to use day labels instead of numbers

The result:

enter image description here

0__
  • 66,707
  • 21
  • 171
  • 266
2

In addition to XYBubbleRenderer, suggested here, also consider a suitable implementation of TableCellRenderer and Icon, illustrated here.

image

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    Good point, thanks. I keep trying with JFreeChart, because I get good quality PDF, which is a bit more work with general Swing components and look-and-feel interaction. – 0__ Oct 14 '13 at 10:15