如何向标签 $MEB$ 添加花括号?

如何向标签 $MEB$ 添加花括号?
\begin{center}
\begin{tikzpicture}
\begin{axis}[
scale = 1.2,
xmin = 0, xmax = 10,
ymin = 0, ymax = 10,
axis lines* = left,
xtick = {0}, ytick = \empty,
clip = false,
xlabel={Quantity of energy efficient housing}, x label style={at=(current axis.right of origin), anchor=west},
ylabel={Price, costs\\and benefits(YEN)}, y label style={align=left, at=(current axis.above origin), anchor=south, rotate=-90},
]

% Colouring areas
\fill[green, opacity = 15] (5, 5) -- (5, 10) -- (7.5,7.5);
% MPB line
\addplot[color = blue, ultra thick] coordinates {(1, 9) (9, 1)};
% MSB line
\addplot[color = blue, ultra thick] coordinates {(4, 11) (11, 4)};
% S line
\addplot[color = red, ultra thick] coordinates {(1, 1) (9, 9)};
% MEB curve
\addplot [color = orange, ultra thick, <->] coordinates {(8,6.85) (8,2.1)};
% E_1 Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 5) (5, 5)
    (5, 0)};
%shaded region
\node [above] at (9.3, 10.7) {Welfare loss};
\draw[-Triangle] (8, 11) to [out = 180, in = 90] (5.5, 7);
% E_opt Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 7.5) (7.5, 7.5)
    (7.5, 0)};
% E_1 Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(5, 5)};
% E_opt Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(7.5, 7.5)};
% Axis Labels
% Equillibrium Labels
\node [right] at (5.2, 5) {$E_1$};
\node [above] at (7.5, 7.7) {$E_{opt}$};
% Price Axis Labels
\node [left] at (0, 5) {$P_M$};
\node [left] at (0, 7.5) {$P_{opt}$};
% Quantity Axis Labels
\node [below] at (5, 0) {$Q_M$};
\node [below] at (7.5, 0) {$Q_{opt}$};
% Line Labels
\node [right] at (8,4) {$MEB$};
\node [right] at (9, 1) {$MPB$};
\node [right] at (9, 9) {$S= MPC= MSC$};
\node [right] at (11,4) {$MSB$};
\end{axis}
\end{tikzpicture}
\captionof{figure}{\textbf{Positive consumption externality in the energy efficient housing market}}
\end{center}

此代码当前产生输出:

在此处输入图片描述

我想用花括号替换那条橙色线。我在这个网站上看到了一些示例,但它们相当混乱且难以理解。我该怎么做?

答案1

像这样吗?

我刚刚更换了线路

\addplot [color = orange, ultra thick, <->] coordinates {(8,6.85) (8,2.1)};

\draw[color=orange, ultra thick, decorate, decoration={brace, amplitude=10pt}]
    (8,6.85) -- (8,2.1) node[midway, right, xshift=10pt, color=black] {$MEB$};

$MEB$并删除了添加标签的行。

这是完整的代码。

\documentclass{article}
\usepackage{pgfplots, tikz}
\usepackage{caption}
\pgfplotsset{compat=1.18}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
scale = 1.2,
xmin = 0, xmax = 10,
ymin = 0, ymax = 10,
axis lines* = left,
xtick = {0}, ytick = \empty,
clip = false,
xlabel={Quantity of energy efficient housing}, x label style={at=(current axis.right of origin), anchor=west},
ylabel={Price, costs\\and benefits(YEN)}, y label style={align=left, at=(current axis.above origin), anchor=south, rotate=-90},
]

% Colouring areas
\fill[green, opacity = 15] (5, 5) -- (5, 10) -- (7.5,7.5);
% MPB line
\addplot[color = blue, ultra thick] coordinates {(1, 9) (9, 1)};
% MSB line
\addplot[color = blue, ultra thick] coordinates {(4, 11) (11, 4)};
% S line
\addplot[color = red, ultra thick] coordinates {(1, 1) (9, 9)};
% MEB curve
\draw[color=orange, ultra thick, decorate, decoration={brace, amplitude=10pt}]
    (8,6.85) -- (8,2.1) node[midway, right, xshift=10pt, color=black] {$MEB$};
% E_1 Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 5) (5, 5)
    (5, 0)};
%shaded region
\node [above] at (9.3, 10.7) {Welfare loss};
\draw[-Triangle] (8, 11) to [out = 180, in = 90] (5.5, 7);
% E_opt Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 7.5) (7.5, 7.5)
    (7.5, 0)};
% E_1 Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(5, 5)};
% E_opt Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(7.5, 7.5)};
% Axis Labels
% Equillibrium Labels
\node [right] at (5.2, 5) {$E_1$};
\node [above] at (7.5, 7.7) {$E_{opt}$};
% Price Axis Labels
\node [left] at (0, 5) {$P_M$};
\node [left] at (0, 7.5) {$P_{opt}$};
% Quantity Axis Labels
\node [below] at (5, 0) {$Q_M$};
\node [below] at (7.5, 0) {$Q_{opt}$};
% Line Labels
\node [right] at (9, 1) {$MPB$};
\node [right] at (9, 9) {$S= MPC= MSC$};
\node [right] at (11,4) {$MSB$};
\end{axis}
\end{tikzpicture}
\captionof{figure}{\textbf{Positive consumption externality in the energy efficient housing market}}
\end{center}
\end{document}

答案2

也许,用一些带有一定幅度的装饰支架就能达到这样的效果:

\addplot [color = orange, ultra thick, decorate, decoration={brace,amplitude=2mm}] coordinates {(8,6.85) (8,2.1)};

\node [right] at (8.2,4.475) {$MEB$};

代替

\addplot [color = orange, ultra thick, <->] coordinates {(8,6.85) (8,2.1)};

\node [right] at (8,4) {$MEB$};


\documentclass[twoside]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{arrows.meta}
\usepackage[singlelinecheck=off,hang]{caption}
\usepackage{refcount}
\usepackage{lipsum}

\newbox\scratchbox

\begin{document}

\noindent\lipsum[1][1-10]

\bigskip

\par\noindent
\ifodd\getrefbykeydefault{MyNicePicture}{page}{1}\expandafter\hbox\else\hfill\null\expandafter\llap\fi
{%
\vbox{%
\label{MyNicePicture}%
\hsize=\paperwidth
\ifodd\getrefbykeydefault{MyNicePicture}{page}{1}\expandafter\raggedright\else\expandafter\raggedleft\fi
\noindent\hbox{%----
\vrule
\vbox{%
\hrule
\hbox{%
\begin{tikzpicture}
\begin{axis}[
scale = 1.2,
xmin = 0, xmax = 10,
ymin = 0, ymax = 10,
axis lines* = left,
xtick = {0}, ytick = \empty,
clip = false,
xlabel={Quantity of energy efficient housing}, x label style={at=(current axis.right of origin), anchor=west, minimum width=4cm},
ylabel={Price, costs\\and benefits(YEN)}, y label style={align=left, at=(current axis.above origin), anchor=south, rotate=-90},
]

% Colouring areas
\fill[green, opacity = 15] (5, 5) -- (5, 10) -- (7.5,7.5);
% MPB line
\addplot[color = blue, ultra thick] coordinates {(1, 9) (9, 1)};
% MSB line
\addplot[color = blue, ultra thick] coordinates {(4, 11) (11, 4)};
% S line
\addplot[color = red, ultra thick] coordinates {(1, 1) (9, 9)};
% MEB curve/brace
\addplot [color = orange, ultra thick, decorate, decoration={brace,amplitude=2mm}] coordinates {(8,6.85) (8,2.1)};
%\addplot [color = orange, ultra thick, decorate, decoration={brace,amplitude=2mm,mirror}] coordinates {(8,6.85) (8,2.1)};
% E_1 Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 5) (5, 5)
    (5, 0)};
%shaded region
\node [above] at (9.3, 10.7) {Welfare loss};
\draw[-Triangle] (8, 11) to [out = 180, in = 90] (5.5, 7);
% E_opt Dashed lines
\addplot[color = black, dashed, very thick] coordinates {(0, 7.5) (7.5, 7.5)
    (7.5, 0)};
% E_1 Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(5, 5)};
% E_opt Coordinate point
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(7.5, 7.5)};
% Axis Labels
% Equillibrium Labels
\node [right] at (5.2, 5) {$E_1$};
\node [above] at (7.5, 7.7) {$E_{opt}$};
% Price Axis Labels
\node [left] at (0, 5) {$P_M$};
\node [left] at (0, 7.5) {$P_{opt}$};
% Quantity Axis Labels
\node [below] at (5, 0) {$Q_M$};
\node [below] at (7.5, 0) {$Q_{opt}$};
% Line Labels
\node [right] at (8.2,4.475) {$MEB$};
%\node  [left] at (7.8,4.475) {$MEB$};
\node [right] at (9, 1) {$MPB$};
\node [right] at (9, 9) {$S= MPC= MSC$};
\node [right] at (11,4) {$MSB$};
\end{axis}
\end{tikzpicture}%
}%---end of hbox
\setbox\scratchbox=\lastbox
\copy\scratchbox
\medskip
\hrule
\medskip
\vbox{%
    \hsize=\wd\scratchbox
    \captionsetup{justification=centering}%
    \captionof{figure}{\textbf{Positive consumption externality in the energy efficient housing market}}%
}%
\hrule
}%---end of vbox
\vrule
}%---end of hbox
}%---end of vbox
}%---end of hbox/llap

\bigskip

\noindent\lipsum[1][1-10]

\end{document}

在此处输入图片描述

相关内容