Constructing a grid date diagram

How can I create a date diagram like that?

Let's say that the counting is done each couple of days, and the right bar represents the counting totals.

• You can construct it using graphics primitives such as Rectangle. What is the input data you would use to make the plot and what have you tried so far? It is not difficult but it takes a bit of work, so it would be great if you could clarify where you got stuck and ask for more specific help ... Mar 1, 2016 at 14:12
• Or you might try ArrayPlot Mar 1, 2016 at 14:21
• Yes, ArrayPlot will be simpler but I think it won't make it possible to draw a frame only around some of the little rectangles. Mar 1, 2016 at 14:37
• clarifying the question, the totals can be simple countings, like this: day 1,2 = 130; day 3,4 = 400; day 5,6= 754; etc... Note that the max count 800 - right bar- could be any number since totals for couple of days could be 1230, 5.000 etc. Or we can stablish a upper limit based on the max totals of a certain day counting. Mar 1, 2016 at 16:04
• To simplify let's assuming countings for each day, forget couples days Mar 1, 2016 at 16:10

If you don't mind a few differences here and there, the biggest bang for the buck is ArrayPlot/MatrixPlot

Suppose you have you data in a nested list, gathered by month

ts[[1,1]] == (* jan/01 *)
ts[[2,20]] == (* feb/20 *)
(* and so on *)


You can plot them directly

MatrixPlot[ts,
ColorFunctionScaling -> False,
ColorFunction -> ColorData[{"PlumColors", {0, 800}}],
PlotLegends -> Automatic,
FrameTicks -> {Thread@{Range[12], monthNames}, Range[2, 31, 2]},
AspectRatio -> 1,
Epilog -> {Red, Thick, Line[{{0, 12 - 3}, {31, 12 - 3}}]}]


If you spend some time with the options (Mesh, FrameTicks, ColorFunction) you might get a better approximation!

• Interesting! I didn't realize that MatrixPlot supported ragged arrays. Unfortunately it doesn't show the raggedness in the mesh (Mesh -> All) Mar 1, 2016 at 15:12
• I must confess I was expecting it to fail at some point, but since it never did... The Mesh issue is why a chose a palette with Black as the zero color, since White is taken as "Null". It's not exactly the same, but I hope it's somehow useful! Mar 1, 2016 at 15:16
• Probably, a temperature color would be better? Mar 1, 2016 at 16:22
• Unfortunately, ColorData["TemperatureMap"] has White as the middle color, and ColorData["VisibleSpectrum"] does not work with the custom range option (a bug, perhaps). Mar 1, 2016 at 18:10