# Plotting a piece-wise function

I've been trying to plot the following function along with a 45 degree line in the first quadrant in LaTeX

$a_{t}^{i}(k_{t}^{i})= \begin{cases} log(1+ck_{t}^{i}) & k_{t}^{i} < \widehat{k} \\ B \frac{(k_{t}^{i})^{1-m}-1}{1-m} & k_{t}^{i} \geq \widehat{k} \end{cases}$


with numerical values for $c$, $B$ and $\widehat{k}$ but pgfplots doesn't recognise log as a function.

The second major concern is that I do not want numbers in the axes as the function is only defined in parameters with no given values and would like to have $\widehat{k}$ marked as a point on the graph among several others. Is there a way to achieve this?

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[ axis lines = left, xlabel = $k_{t}^{i}$, ylabel = {$a_{t}^{i}$}, ]
\addplot[ domain=0:6.12, samples=100, color=red, ] {x};
\addplot [ domain=0:2, samples=100, color=blue, ] {ln(1+2*x)};
\addplot [ domain=2:6.12, samples=100, color=blue, ] {10*((x-0.7)^(-1.5)-1)/(-1.5)};
\end{axis}
\end{tikzpicture}
\end{document}


• Welcome to TeX.SX! This is true. TikZ/PGFPlots only knows ln, log2 and log10. And since PGFPlots calculates plots with numbers, I guess you have to use some numbers for your variables/constants and then simply change the number labels to the variable/constant labels. – Stefan Pinnow Mar 12 '17 at 16:39
• Thanks @StefanPinnow your advice was really helpful and i have been able to plot the log function but can't still get rid of the numbers. My code is as follows. Thank you. \begin{center} \begin{tikzpicture} \begin{axis}[ axis lines = left, xlabel = $k_{t}^{i}$, ylabel = {$a_{t}^{i}$}, ] \addplot[ domain=0:6.12, samples=100, color=red, ] {x}; \addplot [ domain=0:2, samples=100, color=blue, ] {ln(1+2*x)}; \addplot [ domain=2:6.12, samples=100, color=blue, ] {10*((x-0.7)^(-1.5)-1)/(-1.5)}; \end{axis} \end{tikzpicture} \end{center} – Noel Campbell Mar 12 '17 at 16:58
• You can accept my answer if it solved your problem. – Dr. Manuel Kuehner Mar 12 '17 at 18:33
• @NoelCampbell, you are welcome. As a remark: At least your code would have been better suited as an edit to your question, so it is easily copy-able (in a formatted manner). In addition: Did the answer of Dr. Manuel Kuehner help you to solve the remaining question or do you (still) need further assistance? – Stefan Pinnow Mar 12 '17 at 19:02

In general it is required on this site that you provide a complete code example that shows your problem with the minimal required complexity, see here.

I show here how to manually set the tick labels.

\documentclass[border=2mm]{standalone}

%\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
axis lines = left,
xlabel = $k_{t}^{i}$,
ylabel = {$a_{t}^{i}$},
xtick = {2,4},
xticklabels = {{Text at 2},{Text at 4}},
ytick = {2,6},
yticklabels = {{Text at 2},{Text at 6}},
]
domain=0:6.12,
samples=100,
color=red
] {x};
domain=0:2,
samples=100,
color=blue
] {ln(1+2*x)};