5

I want to plot some vertical lines (to mark control points on my histogram).

Code to draw the line looks like:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}
\addplot+[sharp plot] coordinates {(14.5, 0.0) (14.5, 1000)};
\end{loglogaxis}
\end{tikzpicture}
\end{document}

But result looks like first point was just dropped, because there is no value in logarithmic coordinate to be equal zero. How can I draw line from X axis?

3
  • Be more specific. Where do you want to have your first point? If it is at y=0.0, it appears at minus infinity.
    – Turion
    Mar 27 '12 at 12:10
  • I want to draw line from X axis. Like a grid line, but with it's own style and label in legend.
    – iNode
    Mar 27 '12 at 12:21
  • Yes this is a good option in my case. Thank you!
    – iNode
    Mar 27 '12 at 13:26
5

pgfplots comes with a ycomb plot style, which does what you want:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}
\addplot+[ycomb] coordinates {(14.5, 1000)};
\end{loglogaxis}
\end{tikzpicture}
\end{document}
3

Because you are trying to address an inf value on an axis, as far as I know, pgfplots by default discards that (unbounded coords=discard). The quickest fix is to put some small positive value instead of zero and then manually adjust the y axis limits such that the perturbation stays out of the plot.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[ymin=500]
\addplot+[sharp plot] coordinates {(14.5, 0.1) (14.5, 1000)};
\end{loglogaxis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.