在曲线的边缘绘制箭头

Sim*_*mon 10 plot wolfram-mathematica

灵感来自这个问题在ask.sagemath,什么是最好的添加箭头所产生的曲线结束的方式Plot,ContourPlot等等...?这些是高中看到的情节类型,表明曲线在页面末尾继续.

经过一些搜索,我找不到内置方式或最新的包来做到这一点.(有ArrowExtended,但它已经很老了).

ask.sagemath问题中给出的解决方案依赖于函数及其端点的知识以及(可能)获取衍生物的能力.它翻译成Mathematica是

f[x_] := Cos[12 x^2]; xmin = -1; xmax = 1; small = .01; 
Plot[f[x],{x,xmin,xmax}, PlotLabel -> y==f[x], AxesLabel->{x,y},
  Epilog->{Blue,
    Arrow[{{xmin,f[xmin]},{xmin-small,f[xmin-small]}}],
    Arrow[{{xmax,f[xmax]},{xmax+small,f[xmax+small]}}]
  }]
Run Code Online (Sandbox Code Playgroud)

arrow cos(12 x ^ 2)

一种替代的方法是简单地更换Line[]对象生成由Plot[]Arrow[].例如

Plot[{x^2, Sin[10 x], UnitStep[x]}, {x, -1, 1}, 
  PlotStyle -> {Red, Green, {Thick, Blue}},
  (*AxesStyle -> Arrowheads[.03],*) PlotRange -> All] /. 
 Line[x__] :> Sequence[Arrowheads[{-.04, .04}], Arrow[x]]
Run Code Online (Sandbox Code Playgroud)

多个地块

但这有一个问题,就是线条中的任何不连续都会产生你不想要它们的箭头(这通常可以通过选项修复Exclusions -> None).更重要的是,这种方法与CountourPlots 无望.试试吧

ContourPlot[x^2 + y^3 == 1, {x, -2, 2}, {y, -2, 1}] /. 
  Line[x__] :> Sequence[Arrowheads[{-.04, .04}], Arrow[x]]
Run Code Online (Sandbox Code Playgroud)

(上述情况中的问题可以通过规则来确定,例如,{a___, l1_Line, l2_Line, b___} :> {a, Line[Join[l2[[1]], l1[[1]]]], b}或使用适当的单头箭头.).

如您所见,上述(快速黑客)都不是特别强大或灵活.有谁知道这种做法?

Dr.*_*ius 5

通过首先对段进行排序,以下似乎可行:

f[x_] := {E^-x^2, Sin[10 x], Sign[x], Tan[x], UnitBox[x], 
             IntegerPart[x], Gamma[x],
             Piecewise[{{x^2, x < 0}, {x, x > 0}}], {x, x^2}}; 

arrowPlot[f_] := 
 Plot[{#}, {x, -2, 2}, Axes -> False, Frame -> True, PlotRangePadding -> .2] /.

 {Hue[qq__], a___, x___Line} :> {Hue[qq], a, SortBy[{x}, #[[1, 1, 1]] &]} /. 

 {a___,{Line[x___], d___, Line[z__]}} :> 
                           List[Arrowheads[{-.06, 0}], a, Arrow[x], {d}, 
                                             Arrowheads[{0, .06}], Arrow[z]] /. 

 {a___,{Line[x__]}}:> List[Arrowheads[{-.06, 0.06}], a, Arrow[x]] & /@ f[x];  

arrowPlot[f]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述