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 8677 times

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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