当到达路径上的一定距离时是否可以显示标记?
例子
和
\documentclass[10pt,tikz]{standalone}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[]
\addplot[
blue,
domain=0:10,
samples=201,
mark=*,
mark repeat=10]
{exp(x)};
\end{axis}
\end{tikzpicture}
\end{document}
您将获得
虽然我更喜欢的输出是
答案1
您可以使用装饰品。
\documentclass[tikz,border=4mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}
\pgfplotsset{compat=1.11}
\tikzset{mydeco/.style={
decoration={
markings,
mark= between positions 0 and 1 step 5mm with
{
\node[circle,inner sep=2pt,fill=blue]{};
},
},
postaction={decorate}
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[]
\addplot[
blue,
domain=0:10,
samples=201,
mydeco,
%mark=*,
% mark repeat=10
]
{exp(x)};
\end{axis}
\end{tikzpicture}
\end{document}
step 5mm
按照您期望的方式改变tikzset
。
答案2
在等待即将到来的答案时pgfplots
,我忍不住用 MetaPost(在 LuaLaTeX 程序中)做了这件事。至少它可以作为讨论 OP 真正想要什么的基础,这还不清楚(至少对我来说)。我在这里选择了曲线上相隔相同距离的标记……
\documentclass{standalone}
\usepackage{unicode-math}
\usepackage{luamplib}
\mplibsetformat{metafun}
\mplibtextextlabel{enable}
\mplibnumbersystem{double}
\begin{document}
\begin{mplibcode}
% parameters
u = .5cm; v = 0.0002cm;
xmin = -1; xmax = 11; ymin = -.25*(10**4); ymax = 2.5*(10**4);
len = 4bp;
nmarks = 28; % number of marks
% Macro creating a function curve
vardef function_curve(expr xmin, xmax, xsep)(text f_x) =
save f; vardef f(expr x) = f_x enddef ;
(xmin, f(xmin))
for x = xmin+xsep step xsep until xmax+0.9xsep: .. (x, f(x)) endfor
enddef;
% Exponential curve
path expcurve; expcurve = function_curve(0, 10, 0.1)(exp x) xyscaled (u, v);
% Space between marks
marksep = arclength expcurve / (nmarks-1);
beginfig(1);
% Draw curve and marks
draw expcurve;
drawoptions(withpen pencircle scaled 3bp withcolor blue);
draw point epsilon on expcurve; % First mark on the curve
for i = 1 upto nmarks-1:
draw point i*marksep on expcurve; % The other marks
endfor;
% Axes and labels
drawoptions();
draw ((xmin, ymin) -- (xmax, ymin) -- (xmax, ymax) -- (xmin, ymax) -- cycle) xyscaled (u, v);
for i = 0 step 2 until 10:
draw (u*i, ymin*v) -- (u*i, ymin*v+len);
draw (u*i, ymax*v) -- (u*i, ymax*v-len);
label.bot(decimal i, (i*u, ymin*v));
endfor;
for j = 0 step .5*(10**4) until 2*(10**4):
draw (xmin*u, j*v) -- (xmin*u + len, j*v);
draw (xmax*u, j*v) -- (xmax*u - len, j*v) ;
label.lft(decimal (j*(10**-4)), (xmin*u, j*v));
endfor;
label.lft("$\times 10^{4}$", (xmin*u, ymax*v));
setbounds currentpicture to boundingbox currentpicture enlarged 3bp;
endfig;
\end{mplibcode}
\end{document}
结果: