Graphics, Figures & TablesAdditional Line at specific Point on Abscissa

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jhapk
Posts: 81
Joined: Tue Apr 20, 2010 9:33 pm

Additional Line at specific Point on Abscissa

Post by jhapk »

I am plotting some data on a log-log plot using pgfplots and getting the following figure as output.
initial.png
initial.png (49.78 KiB) Viewed 3946 times
I want to add a line manually at a particular value of the x-axis to have a final output of something like this (made using Gimp).
final.png
final.png (48.43 KiB) Viewed 3946 times
How can I do this using pgfplots? My present code looks something like this.

Code: Select all

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
  \begin{tikzpicture}
    \begin{loglogaxis}[
      width=10cm,height=7cm,
      title={longitudnal averages},
      **code**
      **code** 
    ]
      \addplot[
        color=brown,
        thick,
        only marks,
        mark=*,
        table/x = r
      ] table [y=u2]{l_statistics.dat};
      \addplot[
        **code**
        **code** 
        **code**
        **code** 
        **code**
        **code** 
      ]{ncl_statistics.dat};
    \end{loglogaxis}
  \end{tikzpicture}
\end{document}

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

esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm

Additional Line at specific Point on Abscissa

Post by esdd »

Here is an example with an additional line at x=400:

Code: Select all

\documentclass[margin=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
  \begin{loglogaxis}[xlabel=$x$,ylabel=$y$]
    % additional line at x=400:
    \draw(current axis.south-|{axis cs:400,1})%
       --(current axis.north-|{axis cs:400,1})node[right,pos=0.7]{$x=400$};
    \addplot expression[domain=1:10000] {x^-2};
    \end{loglogaxis}
\end{tikzpicture}
\end{document}
loglogline.png
loglogline.png (24.48 KiB) Viewed 3923 times
Regards
Elke
Post Reply