Graphics, Figures & TablesConnecting Line between Points not straight

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Connecting Line between Points not straight

Post by mayankmi »

Hey. I used this code, but the line joining two points (0.5,0.7) to (1,0.7) is not exactly straight. It is a bit curved. I want to make this line straight.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\pgfplotsset{compat=newest}

\begin{document}
  \begin{figure}[!htb]
    \centering
    \begin{tikzpicture}
      \begin{axis}[
        width=12cm,
        height=8cm,  
        grid=both,
        xmin=0,
        xmax=1,
        ymin=0,
        ymax=1.5,
        xlabel={Weighing factor for NDT test (w)},
        ylabel={Trust factor (T)}
      ]
        \addplot[smooth,mark=*,black] plot coordinates {
          (0,1.3)
          (0.5,0.7)
          (1,0.7)
        };
        \addlegendentry{Trust factor  T = 1.3 - 0.5 w};
      \end{axis}
    \end{tikzpicture}
    \caption{Proposed trust factor for NDT tests}
    \label{Proposed trust factor for NDT tests}
  \end{figure}
\end{document}
Attachments
A bit curved instead of straight.
A bit curved instead of straight.
tmp.png (7.29 KiB) Viewed 8755 times

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Connecting Line between Points not straight

Post by Johannes_B »

The first part isn't straight either. Just remove the smooth option from your \addplot command.

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\begin{document}
  \begin{tikzpicture}
    \begin{axis} 
      \addplot[
%        smooth,
        mark=*,
        black
      ] plot coordinates {
        (0,1.3)
        (0.5,0.7)
        (1,0.7)
      };
    \end{axis}
  \end{tikzpicture}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Re: Connecting Line between Points not straight

Post by mayankmi »

ohkk.. now it works... thx
Post Reply