%\documentclass[]{article}
\documentclass[border=3pt, varwidth]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.13}
\begin{document}
% pgfplots.pdf, S. 115
\pgfplotsset{ZahlenAnzeigen/.style={
%TextFarben,
nodes near coords*={
\pgfmathsetmacro{\Nenner}{int(\nenner)}
\ifnum\Nenner=1
$\textcolor{red}{\pgfmathprintnumber[precision=0]\zaehler}$%
\else
${\frac{\pgfmathprintnumber[precision=0]\zaehler}
{\pgfmathprintnumber[precision=0]\nenner}}$%
\fi},
every node near coord/.append style={xshift=0pt,yshift=-7pt, font=\footnotesize}
}}
\tikzset{TextFarben/.style={
r/.style={red}, b/.style={blue}, s/.style={black}
}}
\tikzset{HintergrundFarben/.style={
R/.style={red!50}, B/.style={blue!50}, S/.style={black!50}
}}
\begin{tikzpicture}
\begin{axis}[enlargelimits=0.2]
\addplot[matrix plot,
%mark=*,
only marks, % ohne das geht es nicht
%point meta=\thisrow{color},
ZahlenAnzeigen,
visualization depends on={\thisrow{Z} \as \zaehler},
visualization depends on={\thisrow{N} \as \nenner},
]
table[] {
x y Z N color bgcolor
1 1 1 4 b B