Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the pgfplots manual it says:

\addplot+[smooth]
Smooth plots interpolate smoothly between successive points.

In order to choose the right sampling of points from a function evaluation for plotting, I need to know with some detail what is the "interpolation" that "smooth plot" actually pgfplots (or tikz) implements.

For example, is it cubic splines (probably not), Akima splines, home brew? If it is not a standard one, what properties does it have? continuity, continuity of first derivative, second derivative, monotonicity, maximum tolerated curvature?

share|improve this question
1  
I wonder if this is the same "smooth" as the option in TikZ, e.g. \draw plot[id=sin,smooth] function{sin(x)};. –  N.N. Jul 8 '11 at 10:34
2  
@N.N.: It is. PGFplots uses the TikZ \draw plot function to do the actual plotting. –  Jake Jul 8 '11 at 10:44
    
Thanks, in that case: What is the “smooth” plot interpolation algorithm in tikz? –  alfC Jul 8 '11 at 10:48
2  
@alfC: It uses cubic bézier curves to connect the points of your plot, with the two supports for each point calculated using a relatively simple algorithm that takes the previous and next point into account. Do you want more detail on the algorithm used for determining the supports, or do you already know that this makes TikZ' plotting capabilities unsuitable for you purpose? –  Jake Jul 8 '11 at 11:08
1  
@Jake: I think that is enough information for the complexity of the sampling algorithm I wanted to implement. I think that given the cubic-bezier then there is no simple best adaptive sampling that I can implement quickly. For linear interpolation (i.e. no-smooth) the optimal sampling is given by recursive trapezoidal but for cubic bezier I guess recursive simpson will do at least part of the job. The idea was to plot functions with minimal evaluation points and pdf size the goal being a good resulting "visual plot". –  alfC Jul 8 '11 at 22:13
show 1 more comment

1 Answer 1

up vote 7 down vote accepted

It uses cubic bézier curves to connect the points of your plot, with the two supports for each point calculated using a relatively simple algorithm that takes the previous and next point into account.

share|improve this answer
    
yeah, thanks. I see it can also produce curvature discontinuities in some extreme cases; I guess that is the cost of using a local algorithm. –  alfC Jul 15 '11 at 4:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.