pgfplot: ajusta el estilo de la leyenda y agrega varias rutas

pgfplot: ajusta el estilo de la leyenda y agrega varias rutas

Leí el pgfplotsmanual todo el día, pero lamentablemente no puedo lograr lo siguiente:

(1) legend style: alinee la ecuación de leyenda a la izquierda y modifique el cuadro rectangular a otra forma (o mejor: elimine el cuadro)

(2) agregando líneas discontinuas simples, intenté dibujar caminos, pero no aparecen donde quiero: / por ejemplo, desde x=7la intersección de dos curvas.

\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}

ingrese la descripción de la imagen aquí

Agradecería cualquier comentario adicional sobre cómo hacer que esto se vea mejor. Muchas gracias.

Respuesta1

Para quitar la caja, use draw=noney para alinear ecuaciones a la izquierda, use cells={anchor=west}en

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

Además, debe agregar `\pgfplotsset{compat=1.12} para poder usar

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

de lo contrario, es posible que tengas que usar

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

Código:

\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}

ingrese la descripción de la imagen aquí

Para cambiar la forma, use usetikzlibrary{shapes.geometric}(por ejemplo) y luego

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

da (feo)

ingrese la descripción de la imagen aquí

Con

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

obtenemos

ingrese la descripción de la imagen aquí

información relacionada