tikzpicture에서 화살촉을 제외하는 방법

tikzpicture에서 화살촉을 제외하는 방법

이 이미지에서 화살촉을 자르려고 시도했지만 성공하지 못했습니다. 둘째, 텍스트를 왼쪽 정렬할 수 있는 방법이 있습니까?

\documentclass[10pt,a4paper]{article}        
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,fit,positioning,shapes.symbols,chains}
\usetikzlibrary{positioning} 
\usepackage{caption}
\usetikzlibrary{backgrounds} %border for tikzpicture


\begin{document}

\begin{figure}[h]
\centering
\usetikzlibrary{calc,matrix,decorations.markings,decorations.pathreplacing}

\definecolor{colone}{RGB}{209,220,204}
\definecolor{coltwo}{RGB}{204,222,210}
\definecolor{colthree}{RGB}{207,233,232}
\definecolor{colfour}{RGB}{255,145,100}
\definecolor{colfive}{RGB}{210,240,110}
\definecolor{colsix}{RGB}{243,235,179}
\definecolor{colseven}{RGB}{241,231,163}
%\definecolor{colfive}{RGB}{245,238,197}
\tikzset{ 
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,text width=2cm,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
}
}

\renewcommand*{\familydefault}{\sfdefault}
\newcommand{\cbox}[1]{\parbox[t]{2cm}{\centering #1}}

%\begin{tikzpicture}[thick,scale=0.85, framed]
\begin{tikzpicture}[thick,scale=0.84, every node/.style={scale=0.84}, framed]
\matrix (mat) [table] {
|[fill=colfour]|  & |[fill=colfour]|  & |[fill=colfour]|
& |[fill=colfour]|  & |[fill=colfour]|  &   \\
|[fill=colfive]|  & |[fill=colfive]|  & |[fill=colfive]|
& |[fill=colfive]|  & |[fill=colfive]|  &   \\
|[fill=colsix]|   & |[fill=colsix]|   & |[fill=colsix]|
& |[fill=colsix]|   & |[fill=colsix]|   & |[fill=colsix]|   \\
|[fill=colseven]| & |[fill=colseven]| & |[fill=colseven]|
& |[fill=colseven]| & |[fill=colseven]| & |[fill=colseven]| \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|
& |[fill=coltwo]|   & |[fill=colone]|   & |[fill=colone]|   \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|
& |[fill=coltwo]|   & |[fill=colone]|   & |[fill=colone]|   \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|
& |[fill=coltwo]|   & |[fill=colone]|   &   \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|
& |[fill=coltwo]|   & |[fill=colone]|   &   \\
};

% horizontal rules
\foreach \row in {2,3,4}
\draw[white] (mat-\row-1.north west) -- (mat-\row-6.north east);
\draw[white,ultra thick] (mat-1-1.north west) -- (mat-1-6.north east);
\draw[white,ultra thick] (mat-5-1.north west) -- (mat-5-6.north east);

% vertical rules
\foreach \col in {2,3,4,5}
\draw[white] (mat-5-\col.north west) -- (mat-8-\col.south west);

% The labels
\node[fill=colfour] at (mat-1-3) {First row text required to be left justified };
\node[fill=colfive] at (mat-2-3) {Second row text includes (required left justified)};
\node[fill=colsix] at (mat-3-3) {This is third line in this image(required left justified)};
\node[fill=colseven] at (mat-4-3) {Fourth row (required left justified)};
\node at ([yshift=-10pt]mat-6-1) {\cbox{abcde}};
\node at ([yshift=-10pt]mat-6-2) {\cbox{fghi\\\mbox{}}};
\node at ([yshift=-10pt]mat-6-3) {\cbox{this is cbox}};
\node at ([yshift=-10pt]mat-6-4) {\cbox{this is another cbox}};
\node at ([yshift=-10pt]mat-6-5) {\cbox{this is cbox \\\mbox{}}};
\node[rotate = 90] at ([xshift=-52pt]mat-3-1.north)
{\textsc{Distribution}};
\node at ([yshift=-19pt, xshift=-0.5cm]mat-8-3.south)
{\textsc{Trying to produce this picture excluding arrowhead }};
% Erase some visible lines outside the arrow
\fill[white] (mat-1-5.north east) -- (mat-5-6.north east)
-- (mat-1-6.north east) -- cycle;
\fill[white] (mat-8-5.north east) -- (mat-5-6.north east)
-- (mat-8-6.north east) -- cycle;

% Draw the arrow tip
\shade[top color=colfour!70, bottom color=colfour!70,
middle color=colseven, draw=white, ultra thick] 
(mat-1-5.north) -- (mat-5-6.north) -- (mat-8-5.south) -- 
(mat-8-5.south east) -- (mat-5-6.north east) -- (mat-8-5.south east) -- 
(mat-5-6.north east) -- (mat-1-5.north east) -- cycle;

% The slanted "Margin" labels
\begin{scope}[decoration={markings,
mark=at position .5 with \node[transform shape] {Exclude this arrowhead};}]
\path[postaction={decorate}] 
( $ (mat-1-5.north)!0.5!(mat-1-5.north east) $ )
-- ( $ (mat-5-6.north)!0.5!(mat-5-6.north east) $ );
\path[postaction={decorate}] 
( $ (mat-5-6.north)!0.5!(mat-5-6.north east) $ )
-- ( $ (mat-8-5.south)!0.5!(mat-8-5.south east) $ );
\end{scope}

% The braces
\draw[decorate, decoration={brace, mirror, raise=6pt}]
(mat-1-1.north west) -- (mat-5-1.north west);
\draw[decorate, decoration={brace, mirror, raise=6pt}]
(mat-8-1.south west) -- (mat-8-5.south);

\end{tikzpicture} 
\caption{This is a caption}
\caption*{Source: using tikzlibrary}
\label{fig:1}
\end{figure}
\end{document}

산출

답변1

  • 우선, 주석이 화살표의 일부로 식별되는 세 개의 코드 블록에 주석을 달거나 제거하십시오.
  • 에서 \matrix각 행의 마지막 셀을 삭제합니다. 즉, 마지막 &과 그 사이의 모든 항목을 제거합니다 \\.
  • 코드 블록 도면 가로 규칙에서 열 번호를 6로 바꿉니다 5.
  • 노드의 경우 right옵션에 추가하고 at (mat-rowno-1.west)대신 배치합니다 (mat-rowno-3).

여기에 이미지 설명을 입력하세요

\documentclass[10pt,a4paper]{article}        
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,fit,positioning,shapes.symbols,chains}
\usetikzlibrary{positioning} 
\usepackage{caption}
\usetikzlibrary{backgrounds} %border for tikzpicture


\begin{document}

\begin{figure}[h]
\centering
\usetikzlibrary{calc,matrix,decorations.markings,decorations.pathreplacing}

\definecolor{colone}{RGB}{209,220,204}
\definecolor{coltwo}{RGB}{204,222,210}
\definecolor{colthree}{RGB}{207,233,232}
\definecolor{colfour}{RGB}{255,145,100}
\definecolor{colfive}{RGB}{210,240,110}
\definecolor{colsix}{RGB}{243,235,179}
\definecolor{colseven}{RGB}{241,231,163}
%\definecolor{colfive}{RGB}{245,238,197}
\tikzset{ 
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,text width=2cm,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
}
}

\renewcommand*{\familydefault}{\sfdefault}
\newcommand{\cbox}[1]{\parbox[t]{2cm}{\centering #1}}

%\begin{tikzpicture}[thick,scale=0.85, framed]
\begin{tikzpicture}[thick,scale=0.84, every node/.style={scale=0.84}, framed]
\matrix (mat) [table] {
|[fill=colfour]|  & |[fill=colfour]|  & |[fill=colfour]| & |[fill=colfour]|  & |[fill=colfour]|    \\
|[fill=colfive]|  & |[fill=colfive]|  & |[fill=colfive]| & |[fill=colfive]|  & |[fill=colfive]|    \\
|[fill=colsix]|   & |[fill=colsix]|   & |[fill=colsix]|  & |[fill=colsix]|   & |[fill=colsix]|     \\
|[fill=colseven]| & |[fill=colseven]| & |[fill=colseven]|& |[fill=colseven]| & |[fill=colseven]|   \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|& |[fill=coltwo]|   & |[fill=colone]|     \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|& |[fill=coltwo]|   & |[fill=colone]|     \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|& |[fill=coltwo]|   & |[fill=colone]|     \\
|[fill=colone]|   & |[fill=coltwo]|   & |[fill=colthree]|& |[fill=coltwo]|   & |[fill=colone]|     \\
};

% horizontal rules
\foreach \row in {2,3,4}
   \draw[white] (mat-\row-1.north west) -- (mat-\row-5.north east);  % changed from 6 to 5 in this line
\draw[white,ultra thick] (mat-1-1.north west) -- (mat-1-5.north east);  % changed from 6 to 5 in this line
\draw[white,ultra thick] (mat-5-1.north west) -- (mat-5-5.north east);  % changed from 6 to 5 in this line

% vertical rules
\foreach \col in {2,3,4,5}
\draw[white] (mat-5-\col.north west) -- (mat-8-\col.south west);

% The labels
% added right, and changed coordinate for the following four lines
\node[fill=colfour,right] at (mat-1-1.west) {First row text required to be left justified }; 
\node[fill=colfive,right] at (mat-2-1.west) {Second row text includes (required left justified)};
\node[fill=colsix,right] at (mat-3-1.west) {This is third line in this image(required left justified)};
\node[fill=colseven,right] at (mat-4-1.west) {Fourth row (required left justified)};
\node at ([yshift=-10pt]mat-6-1) {\cbox{abcde}};
\node at ([yshift=-10pt]mat-6-2) {\cbox{fghi\\\mbox{}}};
\node at ([yshift=-10pt]mat-6-3) {\cbox{this is cbox}};
\node at ([yshift=-10pt]mat-6-4) {\cbox{this is another cbox}};
\node at ([yshift=-10pt]mat-6-5) {\cbox{this is cbox \\\mbox{}}};
\node[rotate = 90] at ([xshift=-52pt]mat-3-1.north)
{\textsc{Distribution}};
\node at ([yshift=-19pt, xshift=-0.5cm]mat-8-3.south)
{\textsc{Trying to produce this picture excluding arrowhead }};


% Erase some visible lines outside the arrow
%\fill[] (mat-1-5.north east) -- (mat-5-6.north east)
%-- (mat-1-6.north east) -- cycle;
%\fill[white] (mat-8-5.north east) -- (mat-5-6.north east)
%-- (mat-8-6.north east) -- cycle;

%% Draw the arrow tip
%\shade[top color=colfour!70, bottom color=colfour!70,
%middle color=colseven, draw=white, ultra thick] 
%(mat-1-5.north) -- (mat-5-6.north) -- (mat-8-5.south) -- 
%(mat-8-5.south east) -- (mat-5-6.north east) -- (mat-8-5.south east) -- 
%(mat-5-6.north east) -- (mat-1-5.north east) -- cycle;
%
%% The slanted "Margin" labels
%\begin{scope}[decoration={markings,
%mark=at position .5 with \node[transform shape] {Exclude this arrowhead};}]
%\path[postaction={decorate}] 
%( $ (mat-1-5.north)!0.5!(mat-1-5.north east) $ )
%-- ( $ (mat-5-6.north)!0.5!(mat-5-6.north east) $ );
%\path[postaction={decorate}] 
%( $ (mat-5-6.north)!0.5!(mat-5-6.north east) $ )
%-- ( $ (mat-8-5.south)!0.5!(mat-8-5.south east) $ );
%\end{scope}

% The braces
\draw[decorate, decoration={brace, mirror, raise=6pt}]
(mat-1-1.north west) -- (mat-5-1.north west);
\draw[decorate, decoration={brace, mirror, raise=6pt}]
(mat-8-1.south west) -- (mat-8-5.south east);

\end{tikzpicture} 
\caption{This is a caption}
\caption*{Source: using tikzlibrary}
\label{fig:1}
\end{figure}
\end{document}

관련 정보