Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to create a punchcard so it will look like the same on GitHub with the help of pgfplots?

The data stored in punchcard.dat:

0 Monday 18
1 Monday 67
2 Monday 62
<hour> <day> <commits> 
share|improve this question
    
You can not award yourself a bounty, according to meta.stackexchange.com/questions/54998/… –  Jake Jan 9 '13 at 9:36
    
Oh, they already fix this... –  m0nhawk Jan 9 '13 at 9:37

1 Answer 1

up vote 27 down vote accepted

First I let's take a good color for showing impact:

\definecolor{skyblue}{rgb}{0.447,0.624,0.812} 

Skyblue color! Cool looking and just nice. There is no problem for including pgfplots and give it some options:

\usepackage{pgfplots}
    \pgfplotsset{compat=1.7}

And the most interesting part:

  • first (lines 1 and 2) we open axis environment;
  • on lines 3-7 we define some general options;
  • 9-11: let opacity be 50 * commits / 1000 + 50;
  • 12-13: defining size of mark as 6.5 * commits / 1000 + 1;
  • on lines 14-18 we change size, color and filling of mark.

Finally:

\documentclass{standalone}

\usepackage{mathpazo}
\usepackage{pgfplots}
    \pgfplotsset{compat=newest}

\definecolor{skyblue}{rgb}{0.447,0.624,0.812}

\begin{document}
    \begin{tikzpicture}                                             %1
        \begin{axis}[                                               %2
                grid=major,                                         %3
                point meta=explicit,
                xmin=-1,
                xmax=24,
                xlabel=Hours,                                       %7
                scatter/@pre marker code/.code={
                    \pgfmathparse{                                  %9
                        \pgfplotspointmetatransformed/1000*50+50}   %10
                    \let\opacity=\pgfmathresult                     %11
                    \pgfmathparse{                                  %12
                        \pgfplotspointmetatransformed/1000*6.5+1}   %13
                    \def\markopts{                                  %14
                        mark=*,                                     %15
                        color=skyblue!\opacity,                     %16
                        fill=skyblue!\opacity,                      %17
                        mark size=\pgfmathresult}                   %18
                    \expandafter\scope\expandafter[\markopts]},
                scatter/@post marker code/.code={
                    \endscope},
                symbolic y coords={Sunday,Saturday,Friday,Thursday,Wednesday,Tuesday,Monday},
                xtick={0,...,23},
                x=0.6cm,
                y=0.6cm]
            \addplot[only marks,scatter]
                table[x index=0, y index=1, meta index=2] {punchcard.dat};
        \end{axis}
    \end{tikzpicture}
\end{document}

And the result:

enter image description here

share|improve this answer
6  
Looks great! Minor detail : If pgfplots developer(s) decide to change something in later versions and you keep compat=newest all the time, the code would break down. Just use the version that you have successfully implemented and it would be OK. –  percusse Dec 8 '12 at 16:16
    
@percusse Thanks! Never though of compat= in that way! –  m0nhawk Dec 8 '12 at 16:17
1  
At first I was amazed at how quickly this answer came up! Then I realized you posted the question too :) Nice work :) –  cmhughes Dec 8 '12 at 16:20
3  
Nice solution! Note that in case you need two input parameters in your table instead of just \pgfplotspointmetatransformed, you could use visualization depends on. That, however, would not be mapped automatically. –  Christian Feuersänger Dec 8 '12 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.