如何為圖形添加文字和更正確的鋸齒線?

如何為圖形添加文字和更正確的鋸齒線?

我現在花了幾個小時來創建這個人物 - 但沒有運氣。

我嘗試過不同類型的tikzpstricksusepackages multido

我最大的問題是添加文本,添加更正確的鋸齒線並添加兩條虛線。

在此輸入影像描述

我的程式碼如下所示:

\documentclass{article}
\usepackage{MinionPro}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick,-] (0,0) -- (4.5,0);
\draw[thick,-] (0,0) -- (0,4.5);
\draw[thick,-] (0,0) -- (-4.5,0);
\draw[thick,-] (0,0) -- (0,-4.5);
\draw (0,0) .. controls (0,2) and (2,2) .. (4,2);
\draw (-4,-3) .. controls (-2,-3) and (0,-2) .. (0,0);
\end{tikzpicture}
\end{document}

我得到這個數字: 在此輸入影像描述

答案1

這是 Tikz 的一個簡單解決方案。你可以用圖來做到這一點,但我認為這樣做更容易。

「繪圖」曲線是使用指令繪製的簡單邊緣
\draw (-4.5,-3) edge[out=0,in=180,looseness=1.5] (4.5,3);

正如您所看到的,起點和終點是對稱的。邊緣內部的控制選項指定邊緣的出處(0 度)和入處(180 度)。鬆散度控製曲率:1 為預設值,0 為直線,數字越大,曲線越突出。

圖1

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\tikzset{
    nodeax/.style={
        text centered,
        text width=2.5cm
    },
    every path/.style={
            thick
        }
}

\begin{document}    
\begin{tikzpicture}

%X and Y axis and relative nodes
\draw (-4.5,0) node[nodeax,left] {Expectations failed} -- (4.5,0)  node[nodeax,right] {Expectations exceeded}; % X Axis
\draw (0,-4.5) node[nodeax,below] {Dissatisfied} -- (0,4.5) node[nodeax,above] {Confirmation satisfied}; % Y Axis

% "plot"
\draw (-4.5,-3) edge[out=0,in=180,looseness=1.5] (4.5,3);

% dashed lines and relative nodes
\draw[dashed] (-1,-4.5) -- (-1,4.5) node[left, anchor=east, xshift=-1em] {Discomfirmation};
\draw[dashed] (1,-4.5) -- (1,4.5) 
    node[right, anchor=west, xshift=1em] {Affirmation} 
    node[nodeax,pos=0.3,left, xshift=-8em] {(Difference between perfomance and expectations)};
\end{tikzpicture}   
\end{document}

順便說一句,虛線已添加dashed到路徑選項中,但還有更多:

邊緣圖

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\begin{document}        
\begin{tikzpicture}[
    y=.5cm,
    every node/.style=midway, above, font=\scriptsize
    ]

\draw[densely dashdotted] (0,9) -- (5,9) node {densely dashdotted};
\draw[densely dotted] (0,8) -- (5,8) node {densely dotted};
\draw[densely dashed] (0,7) -- (5,7) node {densely dashed};

\draw[loosely dashdotted] (0,6) -- (5,6) node {loosely dashdotted};
\draw[loosely dotted] (0,5) -- (5,5) node {loosely dotted};
\draw[loosely dashed] (0,4) -- (5,4) node {loosely dashed};

\draw[dashdotted] (0,3) -- (5,3) node {dashdotted};
\draw[dotted] (0,2) -- (5,2) node {dotted};
\draw[dashed] (0,1) -- (5,1) node {dashed};
\draw (0,0) -- (5,0) node {normal};

\end{tikzpicture}
\end{document}

答案2

用 MetaPost 完成。虛線是由運算子繪製的dashed

for k = u, -u: draw (k, ymin) -- (k, ymax) dashed evenly; endfor

MetaPost 手冊,p。 37 了解如何隨意個性化破折號圖案。

此曲線由以下簡單的直線繪製:

draw A{right} .. origin{dir 80} .. B{right};

大括號之間的指令指示切線的方向,由以度為單位的角度指定(right是 的別名dir 0)。

請注意,hobby套件tikz提供了與 MetaPost 類似的用於構建貝塞爾曲線的功能。

input latexmp; setupLaTeXMP(mode=rerun, textextlabel=enable);
numeric u, xmin, xmax, ymin, ymax; 
u = cm; xmax = -xmin = ymax = -ymin = 4.5u;
pair A, B; A = (xmin, -3u); B = (xmax, 2u);
beginfig(1);
  draw (xmin, 0) -- (xmax, 0);
  draw (0, ymin) -- (0, ymax);
  for k = u, -u: draw (k, ymin) -- (k, ymax) dashed evenly; endfor
  draw A{right} .. origin{dir 80} .. B{right};
  label.lft("\begin{tabular}{c}Expectations\\ failed \end{tabular}", (xmin, 0));
  label.rt("\begin{tabular}{c}Expectations\\ exceeded \end{tabular}", (xmax, 0));
  label.bot("Dissatisfied", (0, ymin));
  label.top("\begin{tabular}{c}\textbf{Confirmation}\\Satisfied\end{tabular}", (0, ymax));
  label.top("\textbf{Disconfirmation}", (.4[xmin,-u], ymax));
  label.top("\textbf{Affirmation}", (.5[u,xmax], ymax));
  label.lft("\begin{tabular}{c}Difference between\\Performance and\\Expectations\end{tabular}", (.5[xmin, u], .3ymin));
endfig;
end.

輸出:

在此輸入影像描述

相關內容