1
\documentclass[12pt,a4paper,french]{article}

\usepackage[T1]{fontenc}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows.meta, arrows}
\pagestyle{empty}

\begin{document}

\definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm, scale=.78]
\begin{axis}[
x=20cm,y=100cm,
xlabel = {t(s)} ,
ylabel = {x(m)},
title = ,
axis lines=center,
ymajorgrids=true,
xmajorgrids=true,
xmin=0,
xmax=0.9,
ymin=-0.06307777777777772,
ymax= 0.06307777777777772,
xtick={0,0.1,...,1.7},
ytick={-0.06,-0.049999999999999996,...,0.049999999999999996},]
\clip(-0.1475960421205511,-0.06307777777777772) rectangle (1.7742928467683272,0.053744444444444484);
\draw[line width=3pt,color=sexdts,smooth,samples=100,domain=0:1] plot(\x,{0.04*sin((5*3.141592653589793*(\x)+(7*3.141592653589793)/6)*180/pi)});
\begin{scriptsize}
\draw[color=sexdts] (-0.13346450617283875,0.039355555555555595) node {$f$};
\end{scriptsize}
% \node[below left ] at (0,0) {O};
\end{axis}
\end{tikzpicture}

\end{document}

function

0

Let me guess: you used some software to produce this plot? If you add

ytick scale label code/.code={},
/pgf/number format/precision=1,
/pgf/number format/fixed

to the options of the axis, you get

\documentclass[12pt,a4paper,french]{article}

\usepackage[T1]{fontenc}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows.meta, arrows}
\pagestyle{empty}

\begin{document}

\definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm, scale=.78]
\begin{axis}[
x=20cm,y=100cm,
xlabel = {$t$(s)} ,
ylabel = {$x$(m)},
title = ,
axis lines=center,
ymajorgrids=true,
xmajorgrids=true,
xmin=0,
xmax=0.9,
ymin=-0.06307777777777772,
ymax= 0.06307777777777772,
xtick={0,0.1,...,1.7},
ytick={-0.06,-0.049999999999999996,...,0.049999999999999996},
ytick scale label code/.code={},
/pgf/number format/precision=1,
/pgf/number format/fixed]
\clip(-0.1475960421205511,-0.06307777777777772) rectangle (1.7742928467683272,0.053744444444444484);
\draw[line width=3pt,color=sexdts,smooth,samples=100,domain=0:1] plot(\x,{0.04*sin((5*3.141592653589793*(\x)+(7*3.141592653589793)/6)*180/pi)});
\begin{scriptsize}
\draw[color=sexdts] (-0.13346450617283875,0.039355555555555595) node {$f$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

However, this is still unfortunate in many ways. It would be much better to just use pgfplots without external programs to plot this function.

\documentclass[12pt,a4paper,french]{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{arrows}
\pagestyle{empty}

\begin{document}

\definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
\begin{axis}[width=.95\textwidth,
xlabel = {$t$(s)} ,
ylabel = {$x$(m)},
title = ,
axis lines=center,
ymajorgrids=true,
xmajorgrids=true,
xmin=0,
xmax=0.9,
ymin=-0.063,
ymax= 0.063,
xtick={0,0.1,...,1.7},
ytick={-0.06,-0.05,...,0.05},
/pgf/number format/precision=3,
/pgf/number format/fixed,scaled y ticks=false]
\addplot[line width=3pt,color=sexdts,smooth,samples=100,domain=0:1] 
{0.04*sin((5*pi*x+(7*pi)/6)*180/pi)} node[pos=0.9,above]{$f$};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • You are genius @Schrôdinger's cat, this is what I want. You're right I use Geogebra first as software then try change it after. Could you point out to me great and easy resources to learn pgfplots? Because I plot a lot of functions. – Ousseynou Diagne Oct 15 at 1:08
  • @OusseynouDiagne You're welcome. The pgfplots manual is very good, I think. – Schrödinger's cat Oct 15 at 1:10
  • Thank you, in the last solution, inside the addplot command why did you put times 180/pi ? – Ousseynou Diagne Oct 15 at 1:19
  • @OusseynouDiagne The 180/pi is already present in your code. What I did was to replace 3.141592653589793 by pi. – Schrödinger's cat Oct 15 at 1:49
  • Oh okay, I understood. – Ousseynou Diagne Oct 15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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