我设法对一些现有代码进行了一些调整以满足我的需求。我可以绘制简单的函数。
(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) {};
我懂了: