我想绘制x(2-x²)¹²
区间内的曲线下面积(0,1)
。这是一个高次多项式,我在使用 pgfplot 时遇到了很多问题。
这是我需要使用的格式(不幸的是我不能使用其他格式,我可以缩放所需的一切):
\begin{figure}[h!]
\centering
\begin{tikzpicture}
\fill [blue!20, domain=0:1, variable=\x, samples=2000]
(0, 0) -- plot (\x, {\x*(2-(\x)^2)^12})-- (1,0);
\draw [thick] [->] (0,0)--(1.2,0) node[right, below] {$x$};
\foreach \x in {0.2,0.4,0.6,0.8,1}
\draw[xshift=\x cm, thick] (0pt,-1pt)--(0pt,1pt) node[below] {$\x$};
\draw [thick] [->] (0,0)--(0,800) node[above, left] {$y$};
\foreach \y in {200,400,600}
\draw[yshift=\y cm, thick] (-1pt,0pt)--(1pt,0pt) node[left] {$\y$};
\draw [domain=0:1, variable=\x, line width =1.5pt, samples=2000]
plot (\x, {\x*(2-(\x)^2)^12});
\end{tikzpicture}
\caption*{Representaci\'{o}n gr\'{a}fica de $\displaystyle \int\limits_{0}^{1} x\left(2-x^{2}\right)^{12} dx$}
\end{figure}
我需要得到的数字是这样的:
我一直在 x 轴/y 轴上使用刻度,但总是收到此消息:
"! Dimension too large.<recently read> \pgf@yy l.201 (0, 0)-- plot (\x, {\x*(2-(\x)^2)^12})-- (1,0);"
答案1
欢迎来到 TeX.SX!好吧,你告诉过 Ti钾Z 轴上每隔 200 厘米画一条线,当然,这在页面上放不下。因此出现错误。稍微缩放一下,就可以得到它。
顺便说一下,Ti钾如果您没有指定单位,Z 使用 1cm 作为默认单位。
\documentclass[border=1mm, tikz]{standalone}
\begin{document}
\begin{tikzpicture}[y=.2pt, x=10cm]
\fill [blue!20, domain=0:1, variable=\x, samples=2000]
(0, 0) -- plot (\x, {\x*(2-(\x)^2)^12})-- (1,0);
\draw [thick] [->] (0,0)--(1.2,0) node[right, below] {$x$};
\foreach \x in {0.2,0.4,0.6,0.8,1}
\draw[thick] (\x,-1pt) -- ++(0pt,2pt) node[below] {$\x$};
\draw [thick] [->] (0,0)--(0,800) node[above, left] {$y$};
\foreach \y in {200,400,600}
\draw[thick] (-1pt,\y) -- ++(2pt,0pt) node[left] {$\y$};
\draw [domain=0:1, variable=\x, line width =1.5pt, samples=2000]
plot (\x, {\x*(2-(\x)^2)^12});
\end{tikzpicture}
\end{document}
答案2
这里有一个使用 PGFPlots 的解决方案。
% used PGFPlots v1.18.1
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% use axis lines at origin (instead of a box)
axis lines=center,
% increase the automatically determined axis limits by 5%
enlargelimits=0.05,
% set the function domain (i.e. lower and upper limit)
domain=0:1,
% smooth the line
smooth,
% don't show any markers at the calculated points
no markers,
]
% plot the function (and fill the curve under it)
\addplot+ [fill=.!10] {x * (2 - x^2)^12};
\end{axis}
\end{tikzpicture}
\end{document}