![Tikz 函數和座標系:新增點和標籤](https://rvso.com/image/309883/Tikz%20%E5%87%BD%E6%95%B8%E5%92%8C%E5%BA%A7%E6%A8%99%E7%B3%BB%EF%BC%9A%E6%96%B0%E5%A2%9E%E9%BB%9E%E5%92%8C%E6%A8%99%E7%B1%A4.png)
我設法對一些現有程式碼進行了一些調整以滿足我的需求。我可以繪製簡單的函數。
(1) 我想在座標系上加上標籤,例如 x 軸上的 e (~ 2.71) 和 1/e。
(2) 此外,我喜歡在函數圖上標記特殊點。例如,在座標 x=e 和 y=1 處。
\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{tikz,pgfplots}
\usetikzlibrary{datavisualization.formats.functions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[yscale=.5, xscale=.5, scale=2]
\datavisualization
[school book axes,
legend={below,rows=1},
visualize as smooth line/.list={f1,f2,f3},
f1={style=blue, style=very thick,label in legend={text=$e^x$}},
f2={style=green, style=very thick,label in legend={text=$ln(x)$}},
f3={style=red, style=very thick,label in legend={text=$x$}}
]
data [set=f1, format=function] {
var x : interval[-5:2];
func y = e^(\value x);
}data [set=f2, format=function] {
var x : interval[0.1:5];
func y = ln(\value x);
}data [set=f3, format=function] {
var x : interval[-3:3];
func y = (\value x);
};
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
謝謝 :)
答案1
透過新增這些行:
\draw[shift={(e,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$e$};
\path[draw=red, dashed] (e,0) -- (e,1);
\path[draw=red, dashed] (0,1) -- (e,1);
\node[outer sep=0pt,circle, fill=red,inner sep=1.5pt] (P) at (e,1) {};
我懂了: