
Ich habe pgfplots
den ganzen Tag in der Anleitung gelesen, aber leider schaffe ich es nicht, folgendes zu erreichen:
(1) legend style
: Richten Sie die Legendengleichung linksbündig aus und ändern Sie die rechteckige Box in eine andere Form (oder am besten: entfernen Sie die Box).
(2) Ich habe versucht, durch das Hinzufügen einfacher gestrichelter Linien Pfade zu zeichnen, aber sie erscheinen nicht dort, wo ich sie haben möchte :/ zB vom x=7
Schnittpunkt zweier Kurven.
\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}
Ich freue mich über weitere Hinweise, wie man das Ganze schöner gestalten kann. Vielen Dank.
Antwort1
Zum Entfernen des Kästchens verwenden Sie draw=none
und zum Ausrichten von Gleichungen nach links verwenden Sie cells={anchor=west}
in
legend style={draw=none,font=\tiny,legend pos=outer north east,cells={anchor=west}}
Außerdem müssen Sie `\pgfplotsset{compat=1.12} hinzufügen, um
\path[draw=gray, dashed] (10,-2) -- (10,50);
Andernfalls müssen Sie möglicherweise
\path[draw=gray, dashed] (axis cs:10,-2) -- (axis cs:10,50);
Code:
\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}
Um die Form zu ändern, verwenden Sie usetikzlibrary{shapes.geometric}
(zum Beispiel) und dann
legend style={ellipse,fill=olive,font=\tiny,legend pos=outer north east,cells={anchor=west}}
gibt (hässlich)
Mit
legend style={rounded corners,fill=olive!40,font=\tiny,legend pos=outer north east,cells={anchor=west}}
wir bekommen