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.

I'm trying to plot some points with sudden changes in the slope. But I get some strange behavior like this:

enter image description here

as you can see in the peaks, there is no smoothness in there.

However, I think the problem is the interpolation algorithm, because tikz uses bézier curves. So I'm wondering is there a way to overcome this problem?

I'm putting here just a sample of the data. However, I have several plots with these discontinuities, and I would like to get an automatic way of fixing them. If you need I can show more points in which discontinuities occur.

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotstableread{
0.0000  0.0000
0.1561  0.8615
0.1614  0.8643
0.1669  0.8670
0.3619  0.8670
0.3679  0.8781
0.3739  0.8809
0.3799  0.8809
0.3858  0.8837
0.3918  0.8975
1.0000  1.0000
}\datatable

\begin{document}
\makeatletter
\begin{tikzpicture}
\begin{axis}[
  ylabel=label,
  no markers,
  smooth
]
\addplot table [x index=0, y index=1] \datatable;

\end{axis}
\end{tikzpicture}
\end{document}
share|improve this question
3  
It appears to me as if you have a lot of samples. If you can sample your underlying function so densely, you can probably use the default line style sharp plot instead of smooth. Your example immediately and automatically looks great if you uncomment smooth. Note that smooth should be considered as "draw something somehow nicely" rather than "interpolate strictly using high order interpolation". –  Christian Feuersänger Dec 2 '11 at 20:54
add comment

1 Answer 1

up vote 1 down vote accepted

You can add and play with the tension=0.08 option to the axis (the smaller the number, sharper it gets within the scale [0,1].

But the main problem is you have groups of points too close to each other and suddenly jumps to a higher valued group which constrains the freedom of the turn and makes the interpolation ill-conditioned. I would suggest to leave out the too-close(!) points out, if possible.

share|improve this answer
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.