5

I have a set of data points in a two dimensional space and would like to create a density heat map of the points that looks smooth, similar to the picture below which I produced in MATLAB. Darker regions have a higher concentration of points and vice verse. How can this be done with TikZ? Density Heat Map

  • Can you show us what you've tried so far? – Paul Gessler Apr 5 '14 at 3:06
  • Could you please add MWE of your try or at least the data that solvers could start playing with? – Malipivo Apr 5 '14 at 5:43
  • Addition of many shaded transparent balls? – hpekristiansen Apr 5 '14 at 6:04
2

Here is my best attempt so far:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}
\tikzfading[name=fade out, inner color=transparent!70, outer color=transparent!100]
\begin{tikzpicture}
\newcommand{\heat}[2]{%
  \fill[black,path fading=fade out] (#1,#2) circle (1);
  \begin{pgfonlayer}{foreground}
    \node at (#1,#2) {+};
  \end{pgfonlayer}
}
\foreach \i in {0,...,200}{%
  \pgfmathsetmacro\x{rnd*10}
  \pgfmathsetmacro\y{rnd*10}
  \heat{\x}{\y};
}
\end{tikzpicture}
\end{document}

heatmap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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