
답변1
내 논문에서는 퍼지 멤버십 기능을 표현하기 위해 이와 같은 것을 사용합니다. 이 코드를 귀하의 케이스에 쉽게 적용할 수 있습니다. 이를 위해서는 함수와 해당 채우기를 나타내는 데 사용되는 경로를 변경하고 X축의 레이블을 변경해야 합니다.
다음은 이 코드(lualatex로 컴파일)의 결과입니다.
\documentclass[tikz]{standalone}
\usepackage{xcolor}
\definecolor{RdBu-9-1}{RGB}{178,24,43}
\definecolor{RdBu-9-2}{RGB}{214,96,77}
\definecolor{RdBu-9-3}{RGB}{244,165,130}
\definecolor{RdBu-9-4}{RGB}{253,219,199}
\definecolor{RdBu-9-5}{RGB}{247,247,247}
\definecolor{RdBu-9-6}{RGB}{209,229,240}
\definecolor{RdBu-9-7}{RGB}{146,197,222}
\definecolor{RdBu-9-8}{RGB}{67,147,195}
\definecolor{RdBu-9-9}{RGB}{33,102,172}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
% Styles
\tikzset{%
ffa/.style={%
pattern=north west lines,
pattern color=RdBu-9-2,
draw=none
},
ffa2/.style={%
pattern=north east lines,
pattern color=RdBu-9-8,
draw=none
},
ffa_fade/.style={%
ffa,
path fading=east
},
ffa_fade_m/.style={%
ffa,
path fading=west
},
ffa2_fade/.style={%
ffa2,
path fading=east
},
ffa2_fade_m/.style={%
ffa2,
path fading=west
},
ffc/.style={%
draw=RdBu-9-1,
line width=1
},
ffc2/.style={%
draw=RdBu-9-9,
line width=1
},
% Rendu ligne transparente sans apparition des patterns en dessous
ffc_fade/.style={%
ffc,
draw=white,
postaction={%
draw=RdBu-9-1,
path fading=east
}
},
ffc_fade_m/.style={%
ffc,
draw=white,
postaction={%
draw=RdBu-9-1,
path fading=west
}
},
ffc2_fade/.style={%
ffc2,
draw=white,
postaction={%
draw=RdBu-9-9,
path fading=east
}
},
ffc2_fade_m/.style={%
ffc2,
draw=white,
postaction={%
draw=RdBu-9-9,
path fading=west
}
}
}
\begin{document}
\begin{tikzpicture}
\def\decalageX{-.2}
\def\decalageY{-.2}
% functions
\begin{scope}[transparency group]
\begin{scope}
\path[ffa] (3,0) -- (3.5, 2) -- (5.5,2) -- (6,0) -- cycle;
\path[ffa2] (0,0) -- (0,2) -- (3,2) -- (3.5, 0) -- (5.5,0) --
(6,2) --(9,2) -- (9,0) -- cycle;
\end{scope}
\begin{scope}
\path[ffc] (0,0) -- (3,0) -- (3.5, 2) --(5.5,2) -- (6,0) -- (9,0) ;
\path[ffc2] (0,2) -- (3,2) -- (3.5, 0) -- (5.5,0) -- (6,2) -- (9,2) ;
\end{scope}
\end{scope}
%
% Axis
\begin{scope}
% Axis X
\begin{scope}
% Draw axis
\draw[|-|] (0, \decalageX) --++ (9, 0) coordinate (x axis);
% Add gradiations with a loop
% You can add the labels in the {}, like 2.5/{32}
\foreach \n/\t in {0.5/{},1.5/{},2.5/{},3.5/{},4.5/{},5.5/{},6.5/{},7.5/{},8.5/{}}
{
% Graduation
\draw[-] (\n, \decalageX - .05) --++ (0, .1);
% Graduation label
\node[below, font=\footnotesize] at (\n, \decalageX - .05) {\t};
}
% label of axis
\node[below left, xshift=-.4cm, yshift=-.1cm, font=\small] at (x
axis) {\itshape x value};
\end{scope}
% Axis Y
\begin{scope}
\draw[-] (\decalageY ,0) --++ (0, 2) coordinate (y axis);
% Graduations
\foreach \n/\t in {0/{0},2/{1}}
{
\draw[-] (\decalageY -.05, \n) --++ (.1, 0);
\node[left, font=\footnotesize] at (\decalageY -.05, \n) {\t};
}
% Label
\node[above] at (y axis) {$\mu$};
\end{scope}
\end{scope}
\begin{scope}
% B1
\draw[ffc,line width=.5] (3,\decalageY) -- (3,0);
\draw[fill, RdBu-9-1] (3,\decalageY) circle (2pt);
\draw[fill, RdBu-9-1] (3,0) circle (2pt);
\node[below] at (3,\decalageY) {\(b1\)};
% B2
\draw[ffc,line width=.5] (3.5,\decalageY) -- (3.5,2);
\draw[fill, RdBu-9-1] (3.5,\decalageY) circle (2pt);
\draw[fill, RdBu-9-1] (3.5,2) circle (2pt);
\node[above] at (3.5,2) {\(b2\)};
% B3
\draw[ffc,line width=.5] (5.5,\decalageY) -- (5.5,2);
\draw[fill, RdBu-9-1] (5.5,\decalageY) circle (2pt);
\draw[fill, RdBu-9-1] (5.5,2) circle (2pt);
\node[above] at (5.5,2) {\(b3\)};
% B4
\draw[ffc,line width=.5] (6,\decalageY) -- (6,0);
\draw[fill, RdBu-9-1] (6,\decalageY) circle (2pt);
\draw[fill, RdBu-9-1] (6,0) circle (2pt);
\node[below] at (6,\decalageY) {\(b4\)};
\end{scope}
\end{tikzpicture}
\end{document}