3
$\begingroup$

I am looking for a solution to the arrowheads have different sizes for each arrow, but I am doing something wrong and I am not finding the error. I think it should be obvious, but I am blind.

w = 1/2 (4 - x)^2;   
divisions = 20;  

CargDist = Plot[
  w, {x, 0, 4},
  PlotStyle -> Red,
  PlotRange -> {{-.25, 4}, {-1.5, 8}},
  Epilog -> {Thickness[.004], 
    Arrowheads[#]& /@ Subdivide [0.04, .02, divisions],
    Arrow[({{#1, (1/2)(4 - #1)^2}, {#1, 0}}&) /@ Subdivide[0, 3.2, divisions]],
    EdgeForm[Thick],
    Opacity[0.2],
    Gray,
    Rectangle[{0, -1}, {4, 0}]}]

enter image description here

$\endgroup$
5
$\begingroup$

You really just need a better scaling function for the arrowheads. Also, you must scale each arrowhead separately.

w[x_] := 1/2 (4 - x)^2
With[{divisions = 20},
  Plot[w[x], {x, 0, 4},
    PlotStyle -> Red,
    PlotRange -> {{-.25, 4}, {-1.5, 8}},
    ImageSize -> 500,
    Epilog ->
      {Thickness[.004],
       Table[
         {Arrowheads[.02 w[u]^.5], 
          Arrow[{{u, w[u]}, {u, 0}}]}, {u, Subdivide[0, 3.2, divisions]}],
       EdgeForm[Thick], Opacity[0.2], Gray, Rectangle[{0, -1}, {4, 0}]} ]]

plot

Also note that I did not use a pure function. It is easier to tackle this problem by giving w a conventional function definition.

$\endgroup$
1
  • $\begingroup$ Seems to me very interesting the proposal on the use of the function of pure in Arrowheads[.02 w[u]^.5]. I had not imagined this possibility. $\endgroup$
    – JPeter
    Sep 26 '16 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.