symbolic data on plot in latex

I want to plot some data and for one of them I want to show (0.1,Inf), where Inf stands for infinity. Also, I want yaxis to be in log-scale. I have attached a sample photo of what I want to plot.

Does anyone know how I can do this? Thank you in advance for your help.

• With pstricks, it is very simple: an optional argument of the command \psaxes sets the labels for the axes. – Bernard Dec 30 '19 at 22:31

1 Answer

Welcome! Sure, you can do that. Here is an example.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[declare function={myinf=10^6;},ymode=log,
ymin=100,ymax=10^6,
yticklabel={\ifnum\ticknum=4
Inf
\else
$10^{\the\numexpr\ticknum+2}$
\fi}]
\addplot[mark=star,thick] coordinates {(0.1,myinf) (0.3,myinf) (0.5,10^3)};
\addplot[color=red,mark=o] coordinates {(0.1,10^4.5) (0.3,10^4.1) (0.5,10^4)};
\end{axis}
\end{tikzpicture}
\end{document}


The functions Inf and inf are already taken, so I call the function myinf. Yet this example shows how you can get any symbolic value in the TikZ-pgfplots ecosystem: just declare a function. This can then be used in plots. Changing the ticks is a very standard task in pgfplots.

If you post a code of a use case, there will be a much more automatic solution possible, but at this point I have no idea what you are up to.

• thank you so much – user204090 Dec 31 '19 at 4:07