3

I am making a plot and I would like a tick to appear on the x-axis at the location c/(1 + c) , where c is a constant that I would like to be able to vary. I do not know how to do that. I tried using \usetikzlibrary{calc}, but so far no success.

MWE

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}

\newcommand{\constant}{0.4}

\begin{document}%
\begin{tikzpicture}%
\begin{axis}[%
             xmin = 0,
             xmax = 1,
             xtick = {0,\constant}, % replace 0 by \constant/(1 + \constant)
             ymin = 0,
             ymax = 1
            ]%

\addplot[domain = 0:1] {\constant/(\constant + x)};

\end{axis}%
\end{tikzpicture}%
\end{document}%

1 Answer 1

5

For example:

\documentclass[tikz, border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}

\newcommand{\constant}{0.4}
\usepackage{xintexpr}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
             xmin = 0,
             xmax = 1,
             xtick =
             {\xinttheiexpr[2]\constant/(1+\constant)\relax,\constant}, % replace 0 by \constant/(1 + \constant)
% with 2 digits after decimal mark of precision which seems anyhow to be
% the format kept par tikz here
             ymin = 0,
             ymax = 1
            ]

\addplot[domain = 0:1] {\constant/(\constant + x)};

\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .