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 am trying to plot a naca0012 airfoil profile by its analytic function ( cf wikipedia ) using tikz and I can't understand why I get the following results. I precise that I get the same results if I use gnuplot in tikz \draw plot function. It seems to badly compute the 4 first percent of the plot. If I change to domain=0.:0.05, I also get the 4 first percent of domain=0.:0.05 wrong.

what am I wrong ? Should I specified a tikz option somehow ?

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=10]
  \draw[step=.02,gray,very thin] (-0.1,-0.1) grid (1.1,0.15);

  \draw[color=red,domain=0.:1.,scale=5] plot[id=naca] (\x,{0.12/0.2*(0.2969*sqrt(\x )-0.126*\x -0.3516*\x^2 +0.2843*\x^3 -0.1015*\x^4 )}) ;
  \draw[color=blue,domain=0.:.05,yshift=1] plot[id=naca] (\x,{0.12/0.2*(0.2969*sqrt(\x )-0.126*\x -0.3516*\x^2 +0.2843*\x^3 -0.1015*\x^4 )}) ;

\end{tikzpicture}

\end{document}

produces enter image description here

share|improve this question
    
I am not understanding exactly what is it that is "wrong" with the output? –  Peter Grill Feb 9 '12 at 8:24

1 Answer 1

up vote 6 down vote accepted

The plot is linear between sampling points. To reach a better resolution (and therefore make the plot smoother) use the samples option, i.e.

\draw[domain=0.:1.,samples=400] plot[id=naca] (\x,{0.12/0.2*(0.2969*sqrt(\x )-0.126*\x -0.3516*\x^2 +0.2843*\x^3 -0.1015*\x^4 )}) ; 

You can see the sampling points if you add the marks=+ (or * or x, if your prefer). To adjust for your scaling, the size of the markers need to be reduced.

\draw[domain=0.:1.,samples=100] plot[id=naca,mark=+,mark size=0.1] (\x,{0.12/0.2*(0.2969*sqrt(\x )-0.126*\x -0.3516*\x^2 +0.2843*\x^3 -0.1015*\x^4 )}) ;   

Also, instead of using a high sample count, you can supply smooth to get a better interpolation algorithm.

You may also want to look at the pgfplots package.

share|improve this answer
    
Thanks a lot. Do you know how to plot the sampling points ? –  Sigmun Feb 9 '12 at 9:34
1  
@Sigmun Take a look at my edit. –  Psirus Feb 9 '12 at 9:52

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.