更新 1

更新 1

我的问题是绘制带类别的 XY 轴

我想在我的地块上画三个正方形:

  • 最底下的应该是绿色的,
  • 中间那个是橙色的
  • 最高的一个是红色的。

如果我可以在每个相同颜色的方块中间添加文字,那就太棒了。

以下是我目前所掌握的信息:

在此处输入图片描述

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[nodes near coords, grid=both, ymin=0,ymax=6,xmax=6,xmin=0,
xtick={2,4,6},xticklabels={Low,Middle, High},
ytick={2,4,6}, yticklabels={Low,Middle, High},
xlabel= Classical counterpart,ylabel=Quantization,
every x tick label/.style={xshift=-11mm,anchor=north},
every y tick label/.style={yshift=-8mm,anchor=east}
]
\draw (0,0) rectangle (2,2); %green
\draw (2,2) rectangle (4,4); %orange
\draw (4,4) rectangle (6,6); %red
\end{axis}
\end{tikzpicture}

\end{document}

答案1

更新 1

截屏

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[nodes near coords, grid=both, ymin=0,ymax=6,xmax=6,xmin=0,
xtick={2,4,6},xticklabels={Low,Middle, High},
ytick={2,4,6}, yticklabels={Low,Middle, High},
xlabel= Classical counterpart,ylabel=Quantization,
every x tick label/.style={xshift=-11mm,anchor=north},
every y tick label/.style={yshift=-8mm,anchor=east}
]
\draw[green] (0,0) rectangle (2,2)node[midway]{green};
\draw[orange] (2,2) rectangle (4,4)node[midway]{orange};
\draw[red] (4,4) rectangle (6,6)node[midway]{red};
\end{axis}
\end{tikzpicture}

\end{document}

仅颜色命令(不画出图形的边缘)\fill写一篇文字,就是\node

截屏

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[nodes near coords, grid=both, ymin=0,ymax=6,xmax=6,xmin=0,
xtick={2,4,6},xticklabels={Low,Middle, High},
ytick={2,4,6}, yticklabels={Low,Middle, High},
xlabel= Classical counterpart,ylabel=Quantization,
every x tick label/.style={xshift=-11mm,anchor=north},
every y tick label/.style={yshift=-8mm,anchor=east}
]
\fill[green] (0,0) rectangle (2,2)node[midway,text=blue]{green};
\fill[orange] (2,2) rectangle (4,4)node[midway,text=cyan]{orange};
\fill[red] (4,4) rectangle (6,6)node[midway,text=violet]{red};
\end{axis}
\end{tikzpicture}

\end{document}

相关内容