
Я целый день читал pgfplots
руководство, но, к сожалению, так и не смог добиться следующего:
(1) legend style
: выровняйте легенду-уравнение по левому краю и измените прямоугольный блок на другой (или лучше всего: удалите блок)
(2) добавляя простые пунктирные линии, я пытался рисовать пути, но они не появляются там, где я хочу :/ например, от x=7
до пересечения двух кривых.
\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}}
gives (ugly)
С
legend style={rounded corners,fill=olive!40,font=\tiny,legend pos=outer north east,cells={anchor=west}}
мы получаем