Graphics, Figures & Tablessinus plot not perfect

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
paulosousa
Posts: 90
Joined: Sun Jun 24, 2012 8:48 pm

sinus plot not perfect

Post by paulosousa »

Hello all,
I need your help since the sinus plot is not a perfect curve. Why?

Code: Select all

Code, edit and compile here:
\documentclass[10.5pt, twoside, a4paper]{article}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=2.0cm,top=1.5cm,right=2.0cm,bottom=1.75cm]{geometry}
\usepackage{amsmath,amssymb,amsfonts,textcomp,graphicx}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.5]
\coordinate (O) at (0, 0);
\draw[ultra thick, color=blue][domain=-2.2*pi:2.2*pi] plot (\x,{sin(\x r)}) node[above right] {$f(x) = \sin x$};
\draw[fill=black] (0,-1) circle (0pt) node[ left ]{{\scriptsize $-1$}};
\draw[fill=black] (0,1) circle (0pt) node[ left ]{{\scriptsize $1$}};
\draw[fill=black] (-3.1415,0) circle (0pt) node[below left ]{{\scriptsize $-\pi$}};
\draw[fill=black] (3.1415,0) circle (0pt) node[below left ]{{\scriptsize $\pi$}};
\draw[fill=black] (6.28,0) circle (0pt) node[below right ]{{\scriptsize $2\pi$}};
\draw[fill=black] (-6.28,0) circle (0pt) node[below ]{{\scriptsize $-2\pi$}};
\draw[ultra thick, ->, >=stealth] (-7, 0) -- (8, 0) node[below]{$x$};
\draw[ultra thick, ->, >=stealth] (0,-2.5) -- (0, 2.5) node[left]{$y$};
\end{tikzpicture}
\end{center}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Paulo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

sinus plot not perfect

Post by Johannes_B »

Two points form a line. TiKZ doesn't know what it draws or how it looks and sometimes you need to assist by telling how many samples (points) should be used. Or in this case, a simple smooth helps.

Code: Select all

Code, edit and compile here:
\documentclass[10.5pt,%not valid for article class
twoside, a4paper]{article}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=2.0cm,top=1.5cm,right=2.0cm,bottom=1.75cm]{geometry}
\usepackage{amsmath,amssymb,amsfonts,textcomp,graphicx}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.9]
\coordinate (O) at (0, 0);
\draw[ultra thick, color=blue][domain=-2.2*pi:2.2*pi,samples=20] plot (\x,{sin(\x r)}) node[above right] {$f(x) = \sin x$};
% \draw[ultra thick, color=blue][domain=-2.2*pi:2.2*pi,smooth] plot (\x,{sin(\x r)}) node[above right] {$f(x) = \sin x$};
\draw[ultra thick, color=red][domain=-2.2*pi:2.2*pi,samples=15] plot (\x/2,{2*sin(\x r)}) node[above right] {};
% \draw[ultra thick, color=red][domain=-2.2*pi:2.2*pi,smooth] plot (\x/2,{2*sin(\x r)}) node[above right] {};
\draw[ultra thick, color=green][domain=-2.2*pi:2.2*pi,samples=50] plot (\x,{.5*sin(\x r)}) node[above right] {};
\draw[ultra thick, color=gray][domain=-2.2*pi:2.2*pi,samples=100] plot (\x/2,{3*sin(\x r)}) node[above right] {};
\draw[fill=black] (0,-1) circle (0pt) node[ left ]{{\scriptsize $-1$}};
\draw[fill=black] (0,1) circle (0pt) node[ left ]{{\scriptsize $1$}};
\draw[fill=black] (-3.1415,0) circle (0pt) node[below left ]{{\scriptsize $-\pi$}};
\draw[fill=black] (3.1415,0) circle (0pt) node[below left ]{{\scriptsize $\pi$}};
\draw[fill=black] (6.28,0) circle (0pt) node[below right ]{{\scriptsize $2\pi$}};
\draw[fill=black] (-6.28,0) circle (0pt) node[below ]{{\scriptsize $-2\pi$}};
\draw[ultra thick, ->, >=stealth] (-7, 0) -- (8, 0) node[below]{$x$};
\draw[ultra thick, ->, >=stealth] (0,-2.5) -- (0, 2.5) node[left]{$y$};
\end{tikzpicture}
\end{center}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply