如何更好地格式化这些经济图表?

如何更好地格式化这些经济图表?

编辑:

我现在已经创建了 2 个图表,这是第一个:

% Diagram 1



\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={at=(current axis.above origin), anchor=south, rotate=-90},
]

% Colouring areas
\fill[green, opacity = 0.5] (5, 5) -- (5, 10) -- (7.5,7.5);
% MPB line
\addplot[color = blue, very thick] coordinates {(1, 9) (9, 1)};
% MSB line
\addplot[color = blue, very thick] coordinates {(4, 11) (11, 4)};
% S line
\addplot[color = red, very thick] coordinates {(1, 1) (9, 9)};
% MEB curve
\addplot [color = orange, very thick, <->] coordinates {(8,6.85) (8,2.1)};
% E_1 Dashed lines
\addplot[color = black, dashed, 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, 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}

该代码产生以下输出: enter image description here

以下是图 2 的代码:

%Diagram 2


\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={at=(current axis.above origin), anchor=south, rotate=-90},
]
% Supply and demand curves
\addplot[color = blue, very thick] coordinates {(1, 9) (9, 1)};
\addplot[color = blue, very thick] coordinates {(4, 11) (11, 4)};
\addplot[color = red, very thick] coordinates {(1, 1) (9, 9)};
\addplot[color = red, very thick] coordinates {(4, 1) (11, 8)};
% Dashed lines
\addplot[color = black, dashed, thick] coordinates {(0, 5) (5, 5)
    (5, 0)};
\addplot[color = black, dashed, thick] coordinates {(0, 7.5) (7.5, 7.5)
    (7.5, 0)};
\addplot[color = black, dashed, thick] coordinates {(0, 3.54) (6.54, 3.5)
    (6.5, 0)};
% Coordinate points
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(5, 5)};
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(7.5, 7.5)};
\addplot[color = black, mark = *, only marks, mark size = 3pt]
    coordinates {(6.55, 3.5)};
\node [above] at (5, 5.2) {$E_1$};
\node [above] at (7.5, 7.7) {$E_{opt}$};
\node [above] at (6.5, 3.6) {$E_2$};
\node [left] at (0, 5) {$P_M$};
\node [left] at (0, 3.5) {$P_2$};
\node [left] at (0, 7.5) {$P_{opt}$};
\node [below] at (5, 0) {$Q_M$};
\node [below] at (6.5, 0) {$Q_2$};
\node [below] at (7.5, 0) {$Q_{opt}$};
\node [right] at (9, 1) {$D = MPB$};
\node [right] at (9, 9) {$S = MPC = MSC$};
\node [right] at (11,4) {$MSB$};
\node [right] at (11, 7.7) {$S$ - subsidy};
\end{axis}
\end{tikzpicture}
\captionof{figure}{\textbf{Effects of the subsidy on the energy efficient housing market}}
\end{center}

其结果为:

enter image description here

我如何才能改进轴上标签的格式。更具体地说,如何将其格式化为不连续的一行。图形的标签也是如此。是否可以将其分成两行,这样第二行从第一行开始?

另外,对于图 1,如果我删除注释,\node [right] at (8,4) {$MEB$}那么 overleaf 将拒绝编译,有什么建议可以解决这个问题吗?

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=11,
ymin=0, ymax=10,
axis lines*=left,
xtick={0}, ytick=\empty,
clip=false,
xlabel={Quantity of energy efficient housing},
ylabel={Price, costs\\and benefits}, y label style={align=left, at=(current axis.above origin), anchor=south, rotate=-90},
]
\fill[pink] (5,5) -- (7.5,7.5) -- (5,10) -- cycle;
\addplot[draw=blue, very thick, samples=2] coordinates {(1, 9) (9, 1)} node[right]{$MPB$};
\addplot[draw=blue, very thick, samples=2] coordinates {(4, 11) (11, 4)} node[right] {$MSB$};
\addplot[draw=red, very thick, samples=2] coordinates {(1, 1) (9, 9)} node[right] {$S$};
\addplot[draw=red, very thick, samples=2] coordinates {(4, 1) (11, 8)} node[right] {$S$ + subsidy};
\addplot[dashed, thick, samples=2] coordinates {(0, 5) (5, 5) (5, 0)} node[below] {$Q_E$} node[left, pos=0] {$P_E$};
\addplot[dashed, thick, samples=2] coordinates {(0, 7.5) (7.5, 7.5) (7.5, 0)} node[below] {$Q_{opt}$} node[left, pos=0] {$P_{opt}$};
\addplot[dashed, thick, samples=2] coordinates {(0, 3.54) (6.54, 3.5) (6.5, 0)} node[below] {$Q_2$} node[left, pos=0] {$P_2$};
\addplot[mark = *, only marks, mark size = 3pt] coordinates {(5, 5)} node[above=3pt] {$E_1$};
\addplot[mark = *, only marks, mark size = 3pt] coordinates {(7.5, 7.5)} node[above=3pt] {$E_{opt}$};
\addplot[mark = *, only marks, mark size = 3pt] coordinates {(6.55, 3.5)};
\node[pin={[pin distance=0.6cm, align=left, font=\small, pin edge={black}]70:{Welfare\\loss}}] at (6,8) {};
\end{axis}
\end{tikzpicture}
\end{document}

Graph with lines, nodes and filled area

答案2

当我运行您的示例时,在日志文件中我得到:

Package pgfplots Warning: running in backwards compatibility mode (unsuitable tick labels; missing features). Consider writing \pgfplotsset{compat=1.18} into your preamble.
 on input line 6.

如果我遵循这些指示并添加\pgfplotsset{compat=1.18}到序言中,那么标签就会跳转到更好的位置。

相关内容