5

I am trying to plot the following function

enter image description here

The issue is I do not know what is the best setting for the coordinates. I tried different coordinates with no success. Here is my code:

    \begin{tikzpicture}
\begin{axis}
\addplot[smooth ] coordinates {
(0,45)
(5,40)
(10,35)
(15,30)
(20,25)
(25,20)
(30,15)
(35,10)
(40,5)
(45,10)
(50,15)
(55,20)
(60,25)
(65,30)
(70,35)
(75,40)
(80,35)
(85,35)
(90,35)
(95,35)
(100,35)
(150,30)
(200,28)
(250,25)
(300,25)
(400,24)
(500,21)
(600,18)
(700,17)
(800,15)
(900,10)
(1000,8)
(1024,5)

};
\end{axis}
\end{tikzpicture}

which gives me the following picture.

enter image description here

2
  • 1
    You have a (40,5) couple.
    – Astrinus
    Commented Apr 22, 2015 at 22:05
  • @Astrinus: I can not see the couple couple. Commented Apr 22, 2015 at 22:57

2 Answers 2

9

If you want to reproduce a hand drawn curve and use the smooth interpolation it is better to use less points:

\documentclass[]{standalone}
\usepackage{xcolor}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ytick={30,45},yticklabels={min,max},xtick={10,200,1024},xticklabels={$10$,$20$,$1024$}]
\addplot[smooth] coordinates {
(0,45)
(200,28)
(400,40)
(800,30)
(1024,28)

};
\end{axis}
\end{tikzpicture}
\end{document}

hand

(Note the "fake" x-scale, as in your hand drawn picture)

Alternatively you can plot a function or a polynomial that follows a similar curve: for example cos(x)/x.

1
  • Wow. Never though of it could work with less than 10 points. Thanks
    – seteropere
    Commented Apr 22, 2015 at 22:20
4

You can use plain \draw also inside axis environment.

\documentclass[11pt]{article}

\usepackage{color}
\usepackage{tikz}                           % for flowcharts
%\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
      \begin{tikzpicture}
\begin{axis}[xmin=0,xmax=1100,ymin=0,ymax=50,ytick={12,45},yticklabels={min,max},
xtick={10,200,1024},xticklabels={$10$,$20$,$1024$}]
\draw[rounded corners=10ex]
(0,45) --
(10,45) --
(350,5) --
(700,40)--
(1024,8) --
(1080,8);
\end{axis}
\end{tikzpicture}
\end{document}

Adjust coordinates appropriately to suit your needs.

enter image description here

You must log in to answer this question.

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