带有 4 条曲线的 tikzpicture 需要调整

带有 4 条曲线的 tikzpicture 需要调整

我想复制下面的图像(参见“所需输出”)因为它太模糊+我想更改标签。

我将非常感激任何能让我更接近目标的帮助。

当前代码

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[domain=0:3,scale=1.6,thick]
\usetikzlibrary{calc}   %allows coordinate calculations.

%Define linear parameters for marginal revenue and demand
\def\dintone{5.5}          %Y-intercept for DEMAND_1.
\def\dslpone{-1}         %Slope for DEMAND_1.
\def\mintone{4.5}          %Y-intercept for MR_1.
\def\mslpone{-1.5}          %Slope for MR_1.

\def\dinttwo{2.5}          %Y-intercept for DEMAND_2.
\def\dslptwo{-0.4}         %Slope for DEMAND_2.
\def\minttwo{2}          %Y-intercept for MR_2.
\def\mslptwo{-0.6}          %Slope for MR_2.

\def\pmc{1}           %marginal cost

\def\demandone{\x,{\dslpone*\x+\dintone}}
\def\marginalrevenueone{\x,{\mslpone*\x+\mintone}}

\def\demandtwo{\x,{\dslptwo*\x+\dinttwo}}
\def\marginalrevenuetwo{\x,{\mslptwo*\x+\minttwo}}

% Define coordinates for D_1 and MR_1.
    \coordinate (ints) at ({(\mintone-\dintone)/(\dslpone-\mslpone)},{(\mintone-\dintone)/(\dslpone-\mslpone)*\mslpone+\mintone});
    \coordinate (ep) at  (0,{(\mintone-\dintone)/(\dslpone-\mslpone)*\mslpone+\mintone});
    \coordinate (eq) at  ({(\mintone-\dintone)/(\dslpone-\mslpone)},0);
    \coordinate (dintone) at (0,{\dintone});
    \coordinate (mintone) at (0,{\mintone});
    \coordinate (pfqone) at  ({(\pmc-\dintone)/(\dslpone)},0);
    \coordinate (pfpone) at  ({(\pmc-\dintone)/(\dslpone)},{\pmc});
    \coordinate (mfqone) at  ({(\pmc-\mintone)/(\mslpone)},0);
    \coordinate (mfpone) at  ({(\pmc-\mintone)/(\mslpone)},{\pmc});

% Define coordinates for D_2 and MR_2.
    \coordinate (ints) at ({(\minttwo-\dinttwo)/(\dslptwo-\mslptwo)},{(\minttwo-\dinttwo)/(\dslptwo-\mslptwo)*\mslptwo+\minttwo});
    \coordinate (ep) at  (0,{(\minttwo-\dinttwo)/(\dslptwo-\mslptwo)*\mslptwo+\minttwo});
    \coordinate (eq) at  ({(\minttwo-\dinttwo)/(\dslptwo-\mslptwo)},0);
    \coordinate (dinttwo) at (0,{\dinttwo});
    \coordinate (minttwo) at (0,{\minttwo});
    \coordinate (pfqtwo) at  ({(\pmc-\dinttwo)/(\dslptwo)},0);
    \coordinate (pfptwo) at  ({(\pmc-\dinttwo)/(\dslptwo)},{\pmc});
    \coordinate (mfqtwo) at  ({(\pmc-\minttwo)/(\mslptwo)},0);
    \coordinate (mfptwo) at  ({(\pmc-\minttwo)/(\mslptwo)},{\pmc});    

% DEMAND_1
    \draw[thick,color=blue] plot (\demandone) node[right] {$D_1$};

% MARGINAL REVENUE_1
    \draw[thick,color=blue] plot (\marginalrevenueone) node[right] {$MR_1$};

% DEMAND_2
    \draw[thick,color=black] plot (\demandtwo) node[right] {$D_2$};    

% MARGINAL REVENUE_2
    \draw[thick,color=black] plot (\marginalrevenuetwo) node[right] {$MR_2$};    

% Draw axes, and dotted equilibrium lines.
    \draw[->] (0,0) -- (7,0) node[right] {$Q$};
    \draw[->] (0,0) -- (0,6) node[above] {$P$};

%MC
    \draw[solid,color=red] plot (\x,{\pmc}) node[right] {$MC$};
    \draw[dashed] (mfpone) -- (mfqone) node[below] {$Q_1$};
    \draw[dashed] (mfptwo) -- (mfqtwo) node[below] {$Q_2$};

\end{tikzpicture}

\end{document}

电流输出

在此处输入图片描述

期望输出

在此处输入图片描述

答案1

我必须承认你的代码超出了我的理解能力......

因此我只重绘提供的图像:

在此处输入图片描述

我很确定它可以轻松扩展/适应您的需求。如有必要,可以使用宏将直线替换为曲线plot。上图的 MWE 为:

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{calc, intersections}   %allows coordinate calculations.

\begin{document}
    \begin{tikzpicture}[domain=0:3,scale=1.6,thick]
% coordinates path with intersections
\coordinate (O)     at  (0,0);
\coordinate (MR_1a) at (0.5,5.5);
\coordinate (MR_1b) at (3,1);
% coordinate axes
\draw[->]   (O) -- + (9,0)  node[right] {$Q$};
\draw[->]   (O) -- + (0,6)  node[above] {$P$};
% line AC=MC
\draw[line width=1mm, purple, name path=A]
    (0,3) -- + (7.7,0) node[right] {$AC=MC$};
% line MR_1
\draw[line width=0.8mm, cyan, name path=B]
    (MR_1a) -- (MR_1b) node[below] {$MR_1$};
% line D_1 - AR_1
\draw[line width=0.8mm, cyan, name path=C]
    (1,5.7) -- (5,1.5) node[below] {$D_1-AR_1$};
% line MR_2
\draw[line width=0.8mm, cyan, name path=D]
    (1.5,4.5) -- (7,2) node[right] {$MR_2$};
% line D_2-MR_22
\draw[line width=0.8mm, cyan, name path=E]
    (2,5) -- (7.7,4) node[right] {$D_2-MR_2$};
% coordinates of intersection with path A 
\path [name intersections={of = A and B, by={c1}}] (c1) circle (1mm);
\path [name intersections={of = A and C, by={c2}}] (c2) circle (1mm);
% not drawn paths for determining intersections
\path[name path=F]   (c1) -- + (0,3);
\path[name path=G]   (c2) -- + (0,3);
% intersections
\path [name intersections={of = F and D, by={c3}}];
\path [name intersections={of = G and E, by={c4}}];
% dashed lines
\draw[dashed] 
    (c2 |- O) node[below] {$Q_1$} -- (c4) -- (c4 -| O) node[left] {$P_1$}
    (c1 |- O) node[below] {$Q_2$} -- (c3) -- (c3 -| O) node[left] {$P_2$};
    \end{tikzpicture}
\end{document}

相关内容