0

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.

enter image description here

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

1
  • 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

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}

enter image description here

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.

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

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.