pgfplots : 패치 다이어그램, 개별 직사각형의 색상 변경
Nov 19 2020
- 을 사용하여 "패치 워크"다이어그램을 만들고 싶습니다
pgfplots
. - 나는
patch plots
"Chapter 4.6.13 Patch Plots"를 사용합니다. - 3D 플롯 (서핑, 메쉬 등)에 대한 경험 이 없습니다 .
- 질문 : 사용자 지정 색상으로 사각형을 할당하고 싶습니다 . 가능합니까?
- 또는 MWE에서 like를
point meta
사용할 때 색상 ( )에 어떻게 영향을 줄 수coordinates
있습니까?
배경 : 큰 사각형에 작은 사각형보다 "중요한"색상을 부여하고 싶습니다 .https://windirstat.net/ 또는 http://kdirstat.sourceforge.net/( 스크린 샷 참조 ).
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title = Just a Title,
xmin = 0,
xmax = 100,
colormap/blackwhite, % Just for testing
]
\addplot [
patch,
patch type = rectangle,
] coordinates {
(0,0) (30,0) (30,12) (0,12)
(0,12) (30,12) (30,18) (0,18)
(30,0) (50,0) (50,12) (30,12)
(30,12) (50,12) (50,18) (30,18)
};
\end{axis}
\end{tikzpicture}
\end{document}

답변
1 Noname Nov 20 2020 at 03:42
patchplots
도서관을 사용할 수 있습니다 . 이것은 p의 예입니다. 472를 사용 사례에 맞게 조정했습니다.
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90},
title = Just a Title]
\addplot [table/row sep=\\,
patch,
patch type=polygon,
vertex count=4,
patch table with point meta={
% pt1 pt2 pt3 pt4 cdata
0 1 2 3 2\\
2 3 5 4 1.5\\
1 6 7 2 3\\
2 7 8 4 4\\},
] table {
x y z\\
0 0 0\\%0
30 0 0\\%1
30 12 0\\%2
0 12 0\\%3
30 18 0\\%4
0 18 0\\%5
50 0 0\\%6
50 12 0\\%7
50 18 0\\%8
};
\end{axis}
\end{tikzpicture}
\end{document}

위의 기본 색상 맵인 hot
. 각 색상이 무엇인지 알 수 있도록 직접 정의 할 수 있습니다.
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title = Just a Title]
\addplot [table/row sep=\\,
patch,
patch type=polygon,
vertex count=4,
colormap={custom}{
color(1)=(blue)
color(2)=(green)
color(3)=(orange)
color(4)=(red)
},
patch table with point meta={
% pt1 pt2 pt3 pt4 cdata
0 1 2 3 1\\
2 3 5 4 2\\
1 6 7 2 3\\
2 7 8 4 4\\},
] table {
x y\\
0 0\\%0
30 0\\%1
30 12\\%2
0 12\\%3
30 18\\%4
0 18\\%5
50 0\\%6
50 12\\%7
50 18\\%8
};
\end{axis}
\end{tikzpicture}
\end{document}
