Tikzpicture(pgfplot):修复花括号和标签

Tikzpicture(pgfplot):修复花括号和标签

我有一个主要问题(花括号)和一些我无法解决的小问题:

1) 将第二个花括号向下移动,以便同时标记相对于转折点“E0”的上下间隔(并为标签“债务人/债务人”找到更好的位置)2) 将“最大”值添加到 y=182 和 x=178,我如何将任意符号添加到刻度位置?我可以添加实数 182,但我希望它像“x_2^{\max} \equiv 182”

\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}       
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.12}
\usetikzlibrary{intersections}
\begin{document}
\begin{center} 
\begin{tikzpicture}[scale=1.5]
  \begin{axis}[axis lines=middle,xmin=-1,xmax=189,ymin=-2,ymax=199,
    extra x ticks={178},
        extra y ticks={80, 182},
    xlabel=$\scriptstyle x_1$,
    ylabel=$\scriptstyle x_2$,
        tick label style={font=\tiny}, 
        ]
    \filldraw (100,80) circle (1pt)node[right,font=\tiny] {$E_0$};
    \filldraw (0,182) circle (1pt)node[right,font=\tiny] {$x_2^{\max}$};
        \filldraw (178,0) circle (1pt)node[right,font=\tiny] node[below] {$x_1^{\max}$};
        \addplot+[no marks,blue,domain=0:178,samples=200, thick] {182 - x*(1.02)};
        \path[draw=gray, dashed, thick] (100,0) -- (100,80);
        \path[draw=gray, dashed, thick] (0,80) -- (100,80);
        \draw [decorate, decoration={brace,amplitude=15pt,raise=1pt}] (0,182) -- (100,80)      node [midway, xshift=-1mm, auto, swap, outer sep=10pt,font=\tiny]{debtee};
    \draw [decorate, decoration={brace,amplitude=20pt,raise=2pt,mirror}] (100,80) -- (0,178) 
            node [midway, xshift=3mm, yshift=-1mm,auto, swap, outer sep=10pt,font=\tiny]{debtor};
  \end{axis}
\end{tikzpicture}
\end{center}
\end{document}

我目前的结果是这样的:

在此处输入图片描述

谢谢 :)

答案1

在第二个括号中,使用了以下坐标:

(100,80) -- (0,178)

但是第二对应该反转,因为在这种情况下它在 X 轴上是 0,在 Y 轴上是 178,而它在 Y 上应该是 0,在 X 上应该是 178。此外,删除括号中的这些选项:,,,mirror并修复偏移。autoswap

为了更改额外刻度的标签,请写入extra y tick labels={}并将其更改x为 X 轴。

变化:我为一些节点添加了固定选项(这样它们就不会与括号重叠),并重新定位了轴标签。

输出

图1

代码

\documentclass[12pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{tikz,pgfplots}            

\pgfplotsset{compat=1.12}
\usetikzlibrary{intersections}

\tikzset{
    every pin/.style={font=\tiny, outer sep=0},
    every pin edge/.style={gray,very thin,shorten >=-1mm},
    small dot/.style={fill=black,circle,scale=0.3}
}

\begin{document}
\begin{figure}
    \centering
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
    axis lines=middle,
    xmin=-1, xmax=189,
    ymin=-2, ymax=199,
    extra x ticks={178},
    extra y ticks={80, 182},
    extra y tick labels={80, $x_2^{\max} \equiv 182$},
    xlabel={$\scriptstyle x_1$},
    ylabel={$\scriptstyle x_2$},
    x label style={at={(axis description cs:1,0)},anchor=west},
    y label style={at={(axis description cs:0,1)},anchor=south},
    tick label style={font=\tiny}, 
]

\node[small dot, pin=45:{$E_0$}] at (100,80) {};
\node[small dot, pin=0:{$x_2^{\max}$}] at (0,182) {};
\node[small dot, pin=165:{$x_1^{\max}$}] at (178,0) {};

\addplot+[no marks,blue,domain=0:178,samples=200, thick] {182 - x*(1.02)};

\path [draw=gray, dashed, thick] (100,0) -- (100,80);
\path [draw=gray, dashed, thick] (0,80) -- (100,80);
\draw [decorate, decoration={brace,amplitude=15pt,raise=1pt}] (0,182) -- (100,80) node [midway, anchor=south west, xshift=-1mm, outer sep=10pt,font=\tiny]{debtee};
\draw [decorate, decoration={brace,amplitude=20pt,raise=2pt}] (100,80) -- (178,0) node [midway, anchor=south west, yshift=1mm, xshift=1mm, outer sep=10pt,font=\tiny] {debtor};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

相关内容