
この tikzpicture の青い線のすぐ上に書き込むにはどうすればよいでしょうか?
\begin{tikzpicture}[
scale=5,
IS/.style={blue, thick},
LM/.style={red, thick},
axis/.style={very thick, ->, >=stealth', line join=miter},
important line/.style={thick}, dashed line/.style={dashed, thin},
every node/.style={color=black},
dot/.style={circle,fill=black,minimum size=4pt,inner sep=0pt,
outer sep=-1pt},
]
% axis
\draw[axis,-] (2.5,0) node(xline)[right] {$O_B$} -|
(0,2.5) node(yline)[left] {$w$};
\draw[axis,-](2.5,0)--(2.5,2.5);
\node (0,0) [left]{$O_A$};
\draw[-, Blue] (0,2)--(1.4,.6)
\draw[-, Blue] (2.5,2)--(.8,.6);
\draw[dashed] (0,.87) node[left] {$w_0^*$}--(2.5,.87) node[right] {$w_0^*$};
\node[dot,label=above:$\epsilon_0$] at (1.13,.87) (int1) {};
\draw[dashed] (1.13,0) node[below]{$E_0$}--(1.13,0.87);
\end{tikzpicture}
上記のコードの結果:
この写真の「ABC」や「CBA」のようなものが欲しいです。
答え1
node[pos=0.5,sloped,above]
以下のコードのように使用します。説明:
pos=0.5
ノードをパスの中央に配置します。sloped
挿入された位置でテキストをパスの傾斜と平行になるように回転します。above
説明不要です。
コードの 3 番目のコマンドの末尾にセミコロンが欠落していることに注意してくださいdraw
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[%
scale=5,%
IS/.style={blue, thick},%
LM/.style={red, thick},%
axis/.style={very thick, ->, >=stealth', line join=miter},%
important line/.style={thick}, dashed line/.style={dashed, thin},%
every node/.style={color=black},%
dot/.style={circle,fill=black,minimum size=4pt,inner sep=0pt,%
outer sep=-1pt},%
]
% axis
\draw[axis,-] (2.5,0) node(xline)[right] {$O_B$} -|
(0,2.5) node(yline)[left] {$w$};
\draw[axis,-] (2.5,0) -- (2.5,2.5);
\node (0,0) [left]{$O_A$};
\draw[-, blue] (0,2)--(1.4,.6) node[pos=0.5,sloped,above] {$foo$};
\draw[-, blue] (2.5,2)--(.8,.6) node[pos=0.5,sloped,above] {$bar$};
\draw[dashed] (0,.87) node[left] {$w_0^*$} -- (2.5,.87) node[right] {$w_0^*$};
\node[dot,label=above:$\epsilon_0$] at (1.13,.87) (int1) {};
\draw[dashed] (1.13,0) node[below]{$E_0$}--(1.13,0.87);
\end{tikzpicture}
\end{document}