
次の図をスケッチする最も簡単な方法を誰か教えていただけませんか。以下のコードからわかるように、pgfplots パッケージの axis 環境を使い始めましたが、行き詰まってしまいました。
よろしくお願いします!
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,axis equal,grid=both]
\addplot coordinates{(0,0) (5,5) };
\end{axis}
\end{tikzpicture}
\end{document}
答え1
を使用する必要はないと思いますpgfplots
。 だけを使用しても、必要な効果が得られると思います (そして、いくらか簡単になります) tikz
。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\coordinate (Q) at (0,0);
%% put this first even though you can use opacity.
\coordinate (indifferent/nw) at (-0.5in,0.5in);
\fill[gray,opacity=0.20] (indifferent/nw) rectangle ++ (1in,-1in);
\path (indifferent/nw) ++ (-0.5cm,0.5cm) node[anchor=south east] (indifferent/label) {indifference};
\draw (indifferent/nw) -- (indifferent/label.base east);
\draw[arrows=-Stealth,purple]
(Q) ++ (-2in,0) node [anchor=east,align=center,text width=0.75in]
{Need not~fulfilled}
--
++ (4in,0) node [anchor=west,align=center,text width=0.75in]
{Need well~fulfilled};
\draw[arrows=-Stealth,purple]
(Q) ++ (0,-2in) node [anchor=north,align=center,text width=0.75in]
{dissatisfied}
--
++ (0,4in) node [anchor=south,align=center,text width=0.75in]
{satisfied};
\draw[blue,text=blue]
(Q) ++ (-2in,-2in)
--
++ (4in,4in) node[pos=0.75,anchor=north west] {Performance};
\draw[red,text=red]
(Q) ++ (-2in,0.25cm) .. controls (-0.5cm,0.25cm) and
( 0.5cm,1.00cm)
..
(1.25in,2in)
node[pos=0.95,anchor=south east] {Excitement};
\draw[red,text=red]
(Q) ++ (-1.25in,-2in) .. controls (-0.5cm,-1.00cm) and
( 0.5cm,-0.45cm)
..
(2in,-0.5cm)
node[pos=0.80,anchor=north west] {Basic};
\end{tikzpicture}
\end{document}
ここでの基本的な考え方は、\draw
コマンドは実際にはパスの一種であり、node
それらのパスに沿って を定義できるということです。特に、pos=<val>
ノードのオプション引数で を使用することで、ノードの位置を指定できます。アンカーは、テキストを希望する場所に相対的に配置するのに役立ちます。 text width
との組み合わせは、align
ラベルをx
-軸に沿ってラップして中央に配置するのに役立ちます (以前~
は、well
とfulfilled
をくっつけていました)。最後に、テキストの色も、text=<color>
オプション引数で を使用して指定できます。最後に、 は.. controls (<coordinate>) and (<coordinate>) ..
曲線を構築するために使用しました。今になって、これらを に沿ってもう少し漸近的にするべきだったことに気づきました。パフォーマンスただし、微調整は許可します。
答え2
このような半技術的なスケッチでは、メタポスト代替ツールとして。ここでは、すべてをうまく整理するために、私が好む順序に従いました。パスを定義し (可能な限り相互に相対的に)、パスを描画し、ラベルを追加します。
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
% set a unit scale
u := 1cm;
% define the various paths
path fulfillment, satisfaction, indifference, performance, excitement, basic;
indifference = unitsquare shifted -(1/2,1/2) scaled 2u;
fulfillment = (left--right) scaled 3u;
satisfaction = fulfillment rotated 90;
performance = (xpart point 0 of fulfillment, ypart point 0 of satisfaction)
-- (xpart point 1 of fulfillment, ypart point 1 of satisfaction);
excitement = point 0 of fulfillment shifted (0,1/3u)
{direction 0 of fulfillment} ..
{direction 1 of performance}
point 1 of performance shifted (-1/3u,0);
basic = excitement rotated 180;
% draw the paths
fill indifference withcolor .9 white;
drawarrow fulfillment withcolor .5 white;
drawarrow satisfaction withcolor .5 white;
draw performance withcolor .67 blue;
draw excitement withcolor .67 red;
draw basic withcolor .67 green;
% do the labels
verbatimtex
\font\ss=phvr8r\ss
\def\s#1{$\vcenter{\halign{\hfil{##}\hfil\cr#1\crcr}}$}\let\\\cr
etex
label(btex \s{satisfied} etex, point 1 of satisfaction shifted 10 up);
label(btex \s{dissatisfied} etex, point 0 of satisfaction shifted 10 down);
label(btex \s{needs not\\fulfilled} etex, point 0 of fulfillment shifted 28 left);
label(btex \s{needs well\\fulfilled} etex, point 1 of fulfillment shifted 28 right);
z1 = point 3 of indifference shifted (-u/2,u/2); draw point 3 of indifference -- z1 withcolor .9 white;
label.lft(btex \s{indifference} etex, z1 + 3 up) withcolor .7 white;
label.ulft(btex \s{excitement} etex, point .9 of excitement) withcolor .67 red;
label.lrt (btex \s{performance} etex, point .8 of performance) withcolor .67 blue;
label.lrt (btex \s{basic} etex, point .2 of basic) withcolor .67 green;
endfig;
end.
ノート
上記のリンクには、MP をワークフローに統合するためのさまざまなアプローチが示されており、マニュアルへのリンクもあります。
何が行われているのかをより簡単に理解できるように、すべてのパスにかなり長い名前を使用しました。
u
上部のの値を調整することで、図面のスケールを変更できます。直線のパスには 1 つのセグメントのみがあり、
point 0
開始とpoint 1
終了も 1 つです。を時計回りに 90 度回転した
satisfaction
コピーとして、また を 180 度回転したコピーとして定義しました。これにより、図がきれいに対称的になります。fulfillment
basic
excitement
ラベルをきれいに設定できるように、非常に単純なプレーン TeX コマンドをいくつか定義しました。マニュアルで説明されているように、LaTeX も使用できます。パッケージを使用するか
gmp
、または TikZ のようにluatex
、context
LaTeX ソース ファイルの一部として MP コードを含めることができます。