4

For some reason the plot generated from this code looks extremely ugly. The two series look like they were hand-painted. I thought the smooth property would help but still the same ugly plot.

\documentclass[8pt]{beamer}
\usepackage{pgfplots}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\begin{axis}[domain=-0.015:1.15,
    width=10cm,
    scale only axis,
    xmin=-0.015,
    xmax=1.15,
    height=8cm,
    axis y line=left,
    xlabel=$x_{\alpha}$,
    ylabel=$y_{j}$]
    \addplot [id=logit,color=blue,thick,smooth,mark=x] coordinates   {(-0.0148,-1.56862) (0.02902,-3.28582)(0.06382,-3.28582)(0.12780,-2.56495)(1.13767,-3.33220)};
\end{axis}
\begin{axis}[domain=-0.015:1.15,
    width=10cm,
    scale only axis,
    xmin=-0.015,
    xmax=1.15,
    height=8cm,
    axis y line=right,
    axis x line=none,
    ylabel=$\tau_{j}$]
    \addplot [id=txdef,color=green,thick,smooth,mark=*] coordinates   {(-0.0148,0.17241) (0.02902,0.03571)(0.06382,0.03571)(0.12780,0.07143)(1.13767,0.03448)};
\end{axis}
\end{tikzpicture}


\end{frame}

\end{document}

result

Tobi
  • 56,353
Chedly
  • 515
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Tobi Feb 11 '14 at 13:38
  • 3
    I added an image of the result to your question and the plot looks ok to me. If you get another result you may ry to update your distribution. If the image looks like mine but it shouldn’t please explain in more detail, whats wrong with it … – Tobi Feb 11 '14 at 13:40
  • 1
    And whats the problem with it? I can’t see anything ugly or hand-drawn – Tobi Feb 11 '14 at 15:48
  • Tobi the is extra curvature with the plot that is not supposed to be there. Just look at the first 3 points. – Chedly Feb 11 '14 at 18:27
  • smooth creates that curvature. – Torbjørn T. Feb 11 '14 at 18:44
  • And removing it doesn't help either. I have a similar plot in Excel and it's nowhere similar to the plot above. – Chedly Feb 11 '14 at 18:48
  • Without smooth you'll get straight lines between points, does that not happen for you? – Torbjørn T. Feb 11 '14 at 19:23
  • See here: pgfplots uses cubic bezier splines to make smooth lines. If you want a "nicer" plot give it more data points. – Thruston Feb 11 '14 at 19:25
  • You can also change the 'amount' of curving by adjusting the tension. For example, try smooth,tension=0.1. – Torbjørn T. Feb 11 '14 at 21:50

1 Answers1

2

Here's what the plot looks like when I remove the two smooth keys. Is this what you're trying to achieve? If not, what do you want the plot to look like?

\documentclass{beamer}
\usepackage{pgfplots}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\begin{axis}[domain=-0.015:1.15,
    width=8cm,
    scale only axis,
    xmin=-0.015,
    xmax=1.15,
    height=8cm,
    axis y line=left,
    xlabel=$x_{\alpha}$,
    ylabel=$y_{j}$]
    \addplot [id=logit,color=blue,thick,mark=x] coordinates   {(-0.0148,-1.56862) (0.02902,-3.28582)(0.06382,-3.28582)(0.12780,-2.56495)(1.13767,-3.33220)};
\end{axis}
\begin{axis}[domain=-0.015:1.15,
    width=8cm,
    scale only axis,
    xmin=-0.015,
    xmax=1.15,
    height=8cm,
    axis y line=right,
    axis x line=none,
    ylabel=$\tau_{j}$]
    \addplot [id=txdef,color=green,thick,mark=*] coordinates   {(-0.0148,0.17241) (0.02902,0.03571)(0.06382,0.03571)(0.12780,0.07143)(1.13767,0.03448)};
\end{axis}
\end{tikzpicture}


\end{frame}

\end{document}
Jake
  • 232,450