如何使用 TikZ 在同一张图表中绘制自然对数和十进制对数的图形?

如何使用 TikZ 在同一张图表中绘制自然对数和十进制对数的图形?

我的问题是寻找使用 TikZ 在同一张图表中绘制自然对数和十进制对数图形的代码?

答案1

\documentclass[]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[no marks,axis lines*=middle,samples=101]
\addplot {ln(x)};
\addplot {log10(x)};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-0.95,0.2) -- (5.4,0.2);
\foreach \x in {,1.,2.,3.,4.,5.}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {$\x$};
\draw[->,color=black] (0.1,-2.93) -- (0.,2.02);
\foreach \y in {-2.,-1.,1.,2.}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {$\y$};
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-0.95,-2.93) rectangle (5.38,2.02);
\draw[line width=1.2pt,color=magenta,smooth,samples=100,domain=0.1:7] plot(\x,{ln((\x))});
\draw[line width=1.2pt,color=green,smooth,samples=100,domain=0.1:7] plot(\x,{log10((\x))});
\draw (2.38,1.64) node[anchor=north west] {$f(x)=\ln(x)$};
\draw (2.4,1) node[anchor=north west] {$g(x)=\log_{10}(x)$};
\begin{scriptsize}
\draw[color=magenta] (0.16,-4.54) node {$f$};
\draw[color=green] (0.15,-4.54) node {$g$};
\end{scriptsize}
\end{tikzpicture}
\end{document}

相关内容