1

here is a graph to demonstrate how signal sampling work:

\documentclass[french]{article} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{babel}  
\usepackage{pgfplots}
\usepackage{tikz} % State diagram

\usepgfplotslibrary{fillbetween} % For pgfplot integral
\pgfplotsset{compat=1.12} % For pgfplot integral
\usetikzlibrary{babel} % For pgfplot integral

\pgfplotsset{
standard/.style={
    axis x line=middle,
    axis y line=middle,
    enlarge x limits=0.15,
    enlarge y limits=0.15,
    every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
    every axis y label/.style={at={(current axis.above origin)},anchor=north east},
    every axis plot post/.style={mark options={fill=white}}
    }
}

\begin{document}
\begin{tikzpicture}
        \begin{axis}[
            standard,
            domain = 0:15,
            samples = 16,
            xlabel={$n$},
            xmin=0,
            ylabel={$x[n]$}]
            \addplot+[ycomb,black,thick] {sin(2*180*x/13)};
            \addplot[name path=f, domain=0:15, samples=100, color=blue] {sin(deg(0.485*x))};
            \addplot[draw=none, name path = xaxis, domain=0:15] {0};
            \addplot[orange!50] fill between [of=f and xaxis];
        \end{axis}
\end{tikzpicture}
\end{document}

However, i would like to have the number 8, 10 and 12 above the y line, and all other number below. How can i do that ?

Result

2
  • I saw it @thewaywewalk, but it doesn't work for single label style change.
    – Nakrule
    Dec 15, 2016 at 7:53
  • 1
    Why wouldn't it? Don't you just need xtick={2,4,6,14,16} and extra x ticks={8,10,12}, and the style changes as in that question? Dec 15, 2016 at 9:10

1 Answer 1

4

The duplicate answer works well, also in your case:

\documentclass[french]{article} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{babel}  
\usepackage{pgfplots}
\usepackage{tikz} % State diagram

\usepgfplotslibrary{fillbetween} % For pgfplot integral
\pgfplotsset{compat=1.12} % For pgfplot integral
\usetikzlibrary{babel} % For pgfplot integral

\pgfplotsset{
standard/.style={
    axis x line=middle,
    axis y line=middle,
    enlarge x limits=0.15,
    enlarge y limits=0.15,
    every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
    every axis y label/.style={at={(current axis.above origin)},anchor=north east},
    every axis plot post/.style={mark options={fill=white}}
    }
}

\begin{document}
\begin{tikzpicture}
        \begin{axis}[
            standard,
            domain = 0:15,
            samples = 16,
            xlabel={$n$},
            xmin=0,
            ylabel={$x[n]$},
            xtick={2, 4, 6, 14, 16},
            extra x ticks={8, 10, 12},
            extra x tick style={
                xticklabel style={yshift=0.5ex, anchor=south}
            },            
            ]
            \addplot+[ycomb,black,thick] {sin(2*180*x/13)};
            \addplot[name path=f, domain=0:15, samples=100, color=blue] {sin(deg(0.485*x))};
            \addplot[draw=none, name path = xaxis, domain=0:15] {0};
            \addplot[orange!50] fill between [of=f and xaxis];
        \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Not the answer you're looking for? Browse other questions tagged .