使用 TIKZ 绘制图表时,我遇到了一些缩放问题。我有一个凸包。我希望绘制一条穿过凸包前两个非零顶点(分别为 a 和 b)的抛物线。我计算了系数,以便抛物线穿过凸包的前两个非零顶点。虽然我使比例均匀,但我无法获得所需的结果。这是 MWE
\documentclass[crop,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=.35]
\draw[draw=none,scale=5](0,0)--(-1.1730,0.9848)--(-1.5,0.8660)--(-1.7660,0.6428)--(-1.9397,0.3420)--(-1.9397,-0.3420)--(-1.7660,-0.6428)--(-1.5,-0.8660)--(-1.1730,-0.9848)--(0,0)--cycle;
\draw[thick,scale=5,color=black] (0,0)--(-1.1730,0.9848)--(-1.5,0.8660)--(-1.7660,0.6428)--(-1.9397,0.3420);
\draw[thick,scale=5] (-1.9397,-0.3420)--(-1.7660,-0.6428)--(-1.5,-0.8660)--(-1.1730,-0.9848)--(0,0);
\draw[scale=5, domain=-2:2, smooth, variable=\y, red] plot ({1.48720*\y*\y+2.615340}, {\y});
\node[] at (0.75,0.75) {$0$};
\node[] at (-5.75,5.5) {$a$};
\node[] at (-7.5,5.0) {$b$};
\draw[thick,->,,>=stealth] (-11.5,0)--(2,0) node[right]{$X$};
\draw[thick,->,,>=stealth] (0,-8)--(0,8) node[above]{$Y$};
\end{tikzpicture}
\end{document}
答案1
我尝试重现您的图像:
\documentclass[margin=3mm, tikz]{standalone}
\begin{document}
\begin{tikzpicture}[
T/.style = {font=\scriptsize, fill=white, inner sep=1pt},% ticks
dot/.style = {circle, fill, inner sep=1pt},
scale = 2]
% axis
\draw[thick,-stealth] (-3,0) -- (2,0) node[right] {$X$};
\draw[thick,-stealth] (0,-2) -- (0,2) node[above]{$Y$};
\foreach \i in {-2.5,-2,...,1.5}
\draw (\i,1mm) -- ++ (0,-2mm) node[T, below] {\i};
\foreach \i in {-1.5,-1,-0.5,0.5,1,1.5}
\draw (1mm,\i) -- ++ (-2mm,0) node[T, left] {\i};
% rotated parabola
\draw[domain=0:1.2, variable=\y,
red, very thick] (-3,0) -- plot (3*\y*\y-2.5, \y);%- 1.00456
% a and b points on parabola
\node (a) [dot,label=$a$] at (3*0.5*0.5-2.5,0.5) {};
\node (b) [dot,label=$b$] at (3*0.6*0.6-2.5,0.6) {};
% line
\draw (a) -- ++ (-0.4,-0.3) node[dot] {}
-- ++ (0,-1.2) node[dot] {}
-- ++ (0.4,-0.2) node[dot] {}
-- ++ (0.5,-0.1) node[dot] {}
-- (0,0) node[dot] {}
-- (b);
\end{tikzpicture}
\end{document}