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 created this graph using pgfplot package. Here it is the code I used:

\begin{figure}[htp]
\centering
\begin{tikzpicture}
    \begin{semilogxaxis}[xmin=1e-06,xmax=1e-01,xlabel=packet loss,ylabel=valore atteso,
                         grid=both,
                         legend pos = north west]
    \addplot [smooth,thick,blue]
        file {./MATLAB/grafici/valore_atteso/pure_network_coding/var_pkts_loss_probability/valore_atteso_20nodes_rlnc.txt};
\end{semilogxaxis}
\end{tikzpicture}
\end{figure}

here it is the result I got:

enter image description here

but unfortunately this is not the right graph. This because the file contains those values:

1e-06 1.0022
1e-05 1.0095
0.0001 1.0299
0.001 1.135
0.01 2.1753
0.1 46.922

The curve around 1e-3 and 1e-2 goes down. Why?

share|improve this question
3  
you have added the smooth option. –  percusse Dec 13 '12 at 13:59
    
yeah right...removing smooth it works...but why doesn't work using smooth option?it should follow simply the points –  Mazzy Dec 13 '12 at 14:02
    
If it follows the points then it cannot smoothen. The corners must be modified to be smooth and the degrees of freedom are fixed by the provided points of the curve. A final note I would not touch the data in any log plot (no matter how ugly it can be). The smallest changes are drastic in the actual magnitudes. –  percusse Dec 13 '12 at 14:03
2  
The curve should go through all the points (try adding mark=* to see where your points are), but between the points, the curve changes of course, otherwise it wouldn't be smooth, as percusse said. –  Jake Dec 13 '12 at 14:05
1  
mark size=<value> –  Jake Dec 13 '12 at 14:09

1 Answer 1

up vote 5 down vote accepted

smooth option enables a path morphing mechanism such that the sharp corners are eliminated via some Bézier curve construction. As the name implies the curve is morphed into a smoother one. The only relation with the original curve is the given fixed points that define the curvature of the path while passing through those points.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[] coordinates {(0,0) (1,1) (2,2) (3,0) (3.3,0.5)};
\addplot+[smooth,ultra thick] coordinates {(0,0) (1,1) (2,2) (3,0) (3.3,0.5)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

In drawings and schematics this is no big deal and can be used safely. However as you have found out, scientific plots should be given without any modification. Especially in the logarithmic plot cases the smallest deviations mean a lot in the linear scale.

share|improve this answer

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.