I am plotting a function that needs to be evaluated on numerous samples on some parts to avoid visible mistakes, even with the smooth option. To avoid using too many where the samples are not needed, I had cut my plot in several domain, and each had its own \addplot with a chosen number of samples. It was messy programming and it has some minor graphical mishaps.
So when I came across samples at, I wanted to try it, but quite unsuccessfully :
Here is the simplified code :
\documentclass[border=2pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz,pgfplots}
\newcommand*{\addZreModif}[2]{
%\addplot[#2,thick=3pt,ultra thick,samples at={0,((2*pi/W)/500),...,((2*pi/W)/10),((2*pi/W)*1.1/10),...,(2*pi/W),(2*pi*1.02/W),...,(4*pi/W),...,Ttrace}] {
\addplot[#2,thick=3pt,ultra thick,samples at={0,((2*pi/W)/500),...,((2*pi/W)/10)}] {
( 1 - ( (exp(-W*#1*x)/sqrt(1-#1^2)) *cos((W*x*sqrt(1-#1^2)
- (atan(#1/sqrt(1-#1^2))*pi/180) ) *180/pi) ) ) *\Kg };
}
\begin{document}
\begin{tikzpicture}[
declare function={
W=pi*2;
Ttrace=3;
}]
\def\Kg{2}
\def\Ezero{1}
\begin{axis}
\addZreModif{0.2}{red,dotted}
\end{axis}
\end{tikzpicture}
\end{document}
The interesting bit lies inside the \newcommand, in the options of the addplot:
this one:
\addplot[#2,thick=3pt,ultra thick,samples at={0,((2*pi/W)/500),...,((2*pi/W)/10)}] {
is the working one. It represents the first domain (the start of the curve, with an horizontal starting slop I don't want to miss) with 50 points
The longer one, commented in the presented code :
\addplot[#2,thick=3pt,ultra thick,samples at={0,((2*pi/W)/500),...,((2*pi/W)/10),((2*pi/W)*1.1/10),...,(2*pi/W),(2*pi*1.02/W),...,(4*pi/W),...,Ttrace}] {
is the one I wished to use, based on examples I've seen of sample at but it doesn't compute and that's why I'm here. by the way I've seen two writings :
samples at={0,firstStep1,...,end1,firstStep2,...,end2}
and
samples at={0,firstStep1,...,end1,end1,firstStep2,...end2}
I don't which is right, I've tried both without success...
I tried :
\addplot[#2,thick=3pt,ultra thick,samples at={0,(1/500),...,(1/10),(1.1/10),...,1}] {
and
\addplot[#2,thick=3pt,ultra thick,samples at={0,(1/500),...,(1/10),(1/10),(1.1/10),...,1}] {
If you can tell me what's wrong, thanks in advance.
