pgfplot: 凡例のスタイルを調整し、いくつかのパスを追加します

pgfplot: 凡例のスタイルを調整し、いくつかのパスを追加します

pgfplots一日中マニュアルを読みましたが、残念ながら次のことは達成できませんでした。

(1)legend style凡例を左揃えにし、長方形のボックスを別の形に変更する(またはボックスを削除するのがベスト)

(2)単純な破線を追加してパスを描画しようとしましたが、パスが希望する場所に表示されません。例:x=72つの曲線の交差点から。

\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{tikz,pgfplots}
\usepackage{amsmath,amssymb,stmaryrd}
\begin{document}

  \begin{tikzpicture}[scale=1]
      \begin{axis}[axis lines=middle,xmin=-5,xmax=16,ymin=2,ymax=299,
        extra x ticks={0,4,7},
        tick label style={font=\tiny}, 
        legend style={font=\tiny,legend pos=outer north east}
            ]
            \addplot+[no marks,blue,domain=0.2:10,samples=150, thick] {(x)^3 - 12*(x)^2 + 60*x+98};
        \addlegendentry{$C(x) = x^3 - 12x^2 + 60x+98$};
            \addplot+[no marks,red,domain=0.2:13,samples=150, thick] {3*(x)^2 - 24*x + 60};
            \addlegendentry{$MC(x)=3x^2 - 24x + 60$};
            \addplot+[no marks,orange,domain=0.2:13,samples=150, thick] {(x)^2 - 12*x + 60 + (98)/(x)};
            \addlegendentry{$AV(x)=x^2 - 12x + 60 + \frac{98}{x}$};
            \path[draw=gray, dashed] (4,2) -- (4,50); 
            \path[draw=gray, dashed] (10,-2) -- (10,50); 
      \end{axis}
    \end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

これをもっと見栄え良くする方法について、さらにコメントをいただければ幸いです。 ありがとうございます。

答え1

ボックスを削除するには、 を使用しdraw=none、方程式を左揃えにするには、 を使用しますcells={anchor=west}

legend style={draw=none,font=\tiny,legend pos=outer north east,cells={anchor=west}}

さらに、`\pgfplotsset{compat=1.12}を追加する必要があります。

\path[draw=gray, dashed] (10,-2) -- (10,50);

そうでなければ、

\path[draw=gray, dashed] (axis cs:10,-2) -- (axis cs:10,50);

コード:

\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}

  \begin{tikzpicture}[scale=1]
      \begin{axis}[axis lines=middle,xmin=-5,xmax=16,ymin=2,ymax=299,
        extra x ticks={0,4,7},
        tick label style={font=\tiny},
        legend style={draw=none,font=\tiny,legend pos=outer north east,cells={anchor=west}}
            ]
            \addplot+[no marks,blue,domain=0.2:10,samples=150, thick] {(x)^3 - 12*(x)^2 + 60*x+98};
        \addlegendentry{$C(x) = x^3 - 12x^2 + 60x+98$};
            \addplot+[no marks,red,domain=0.2:13,samples=150, thick] {3*(x)^2 - 24*x + 60};
            \addlegendentry{$MC(x)=3x^2 - 24x + 60$};
            \addplot+[no marks,orange,domain=0.2:13,samples=150, thick] {(x)^2 - 12*x + 60 + (98)/(x)};
            \addlegendentry{$AV(x)=x^2 - 12x + 60 + \frac{98}{x}$};
            \path[draw=gray, dashed] (4,2) -- (4,50);
            \path[draw=gray, dashed] (10,-2) -- (10,50);
      \end{axis}
    \end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

形状を変更するには、usetikzlibrary{shapes.geometric}(例えば)を使用してから

legend style={ellipse,fill=olive,font=\tiny,legend pos=outer north east,cells={anchor=west}}

(醜い)

ここに画像の説明を入力してください

legend style={rounded corners,fill=olive!40,font=\tiny,legend pos=outer north east,cells={anchor=west}}

我々が得る

ここに画像の説明を入力してください

関連情報