TeX - LaTeX Asked by BuenoGrande on January 16, 2021
My question is a follow-up question from Drawing a XY axis with categories
I would like to draw three squares on my plot:
It would be fantastic if I could add a text in the middle of each square of the same color.
Here is what I have so far:
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}
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}
The command to only color (without drawing the edges of the figure) is fill
To write a text, it is 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}
Correct answer by AndréC on January 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP