当降低矩阵图的不透明度时,我发现单元格重叠。如何消除这种重叠?
请考虑以下示例:
\documentclass[]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{filecontents}{tmp.dat}
-1 1 0.5
-1 0 1
-1 -1 1
0 1 1
0 0 1
0 -1 1
1 1 1
1 0 1
1 -1 1
\end{filecontents}
\begin{tikzpicture}
\begin{axis} [
enlargelimits=false,
axis equal
]
\addplot
[
matrix plot*,
mesh/cols = 3,
point meta = explicit,
opacity = 0.5
] file {
tmp.dat
};
\end{axis}
\end{tikzpicture}
\end{document}
我使用 进行编译pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex
。
答案1
使用柔和的颜色代替[opacity=0.5]
:
\documentclass[]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{filecontents}{tmp.dat}
-1 1 0.5
-1 0 1
-1 -1 1
0 1 1
0 0 1
0 -1 1
1 1 1
1 0 1
1 -1 1
\end{filecontents}
\begin{tikzpicture}
\begin{axis} [
enlargelimits=false,
axis equal,
colormap={soft}{color=(blue!50!white) color=(yellow!50!white) color=(orange!50!white) color=(red!50!white)}
]
\addplot
[
matrix plot*,
mesh/cols = 3,
point meta = explicit,
] file {
tmp.dat
};
\end{axis}
\end{tikzpicture}
\end{document}