I want to Create confusion matrix 5×5 in Latex (overleaf), background same color blue.
I used this code:
\begin{tikzpicture}
\begin{axis}[
colormap={bluewhite}{color=(white) rgb255=(90,96,191)},
xlabel=Predicted,
xlabel style={yshift=-30pt},
ylabel=Actual,
ylabel style={yshift=20pt},
xticklabels={W1, W2, W3, W4},
xtick={0,...,3},
xtick style={draw=none},
yticklabels={W1, W2, W3, W4},
ytick={0,...,3},
ytick style={draw=none},
enlargelimits=false,
colorbar,
xticklabel style={
rotate=90
},
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta},
nodes near coords style={
yshift=-7pt
},
]
\addplot[
matrix plot,
mesh/cols=4,
point meta=explicit,draw=gray
] table [meta=C] {
x y C
0 0 0.96
1 0 0.1
2 0 0
3 0 0
0 1 0.1
1 1 0.98
2 1 1
3 1 0.1
0 2 0
1 2 0
2 2 0.97
3 2 0.3
0 3 0.3
1 3 0
2 3 0
3 3 1
};
\end{axis}
\end{tikzpicture}
How I can add fifth column ( W5)?
Best Answer
I'm still confused about why you were confused. I essentially looked through the code for every "4" (or "3") and incremented. The only difficulty is that I couldn't have comments within the
\addplot
.For an output of