TeX - LaTeX Asked by Harith on June 25, 2021
I’m using PGFPlots to generate graphs of functions. I use smooth
to smooth out the curve, but it isn’t smooth enough. So I tried increasing the samples
option. The problem is, I can go all the way to samples=9000
yet the graph won’t draw until the end. Here are some pictures:
Using just smooth
:
Using smooth
and samples=10
:
Using smooth
and samples=950
:
Using smooth
and samples=2950
:
As can be seen, using just smooth
yields a lumpy picture, whereas using high samples
along with smooth
gives a great curve, but doesn’t go up to the x-axis, as it should, and using highersamples
values seems to give diminishing returns.
Code:
documentclass[margin=5mmm, tikz]{standalone}
usepackage{pgfplots}
usepackage{tikz}
usepgfplotslibrary{fillbetween}
pgfplotsset{compat=1.8}
begin{document}
begin{tikzpicture}[xscale = 1.7]
begin{axis}
[
xmin=0,xmax=4,
ymin=0,ymax=12,
axis x line=middle,
axis y line=middle,
axis line style=->,
ticks=none,
]
% The line below is the important one
addplot[name path = c, color=blue, domain=0:4, samples=950, smooth]{x^2 * (9 - x^2)^0.5};
addplot[name path = a, domain=0:4]{0};
addplot [
thick,
color=blue,
fill=blue,
fill opacity=0.05
]
fill between[
of=a and c,
];
end{axis}
end{tikzpicture}
end{document}
I’m adding the code to highlight under the graph where you can see how the colored area acts weird because it might be useful to you to see the strange behavior of the curve when samples are used.
Is there any way to fix this, i.e. get a smooth curve without this happening?
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP