4
$\begingroup$

I am plotting very tiny arrows. For large arrows there is no problem but for small ones, one can see little crosses in the arrow positions. I do not want to see this crosses. I just want to see no arrow if it is too small. The parameter a controls the length of the arrow. Here a very simple example:

a = 10^-8;
listb = {{{0, 0}, {2.1*a, -2.1*a}}, {{1, 0}, {2.1*a, 2.1*a}}};
Graphics[{Arrowheads[Norm@#2/0.0001], Arrow[{#1, #1 + #2}]} & @@@ listb]

How could I get rid of the tiny crosses?

Thank you.

$\endgroup$
3
$\begingroup$

Just add a replacement at the end:

Graphics[{Arrowheads[Norm@#2/0.0001], Arrow[{#1, #1 + #2}]} & @@@ listb] /. 
  {_Arrowheads, Arrow[{a_, b_}] /; Norm[a - b] <= 10^-7} -> {}

Update

The problem seems to be a dot at the end of the arrow under certain conditions.

a = 10^-8; listb = {{{0, 0}, {2.1*a, -2.1*a}}, {{1, 0}, {2.1*a, 
    2.1*a}}}; 
Graphics[{Arrowheads[Norm@#2/0.000001], Arrow[{#1, #1 + #2}]} & @@@ listb]

Mathematica graphics

enlarged:

Mathematica graphics

I assume that is a consequence of the underlying graphics code used to draw it. If this is a problem, you could use an arrow head of your own, like:

h = Graphics[Polygon[.5 {{-1, 1/2}, {0, 0}, {-1, -1/2}, {-.8, 0}}]]; 

and then:

a = 10^-8; listb = {{{0, 0}, {2.1*a, -2.1*a}}, {{1, 0}, {2.1*a, 2.1*a}}}; 

Graphics[{Arrowheads[{{Norm@#2/0.000001, Automatic, h}}], 
          Arrow[{#1, #1 + #2}]} & @@@ listb]

Mathematica graphics

enlarged:

Mathematica graphics

$\endgroup$
  • $\begingroup$ Is the problem the size of the arrowhead of the length of the line? I take it to be the arrowhead. $\endgroup$ – Mr.Wizard Jun 24 '15 at 9:50
  • $\begingroup$ It's not clear to me. I didn't see any crosses with the code posted in the question, just two dots, so I figured the OP wanted to get rid of those. (" I just want to see no arrow if it is too small.") $\endgroup$ – Sjoerd C. de Vries Jun 24 '15 at 9:52
  • $\begingroup$ I figured the same. I think the issue is that very small arrowheads still render as dots (to a point) whereas lines disappear sooner. $\endgroup$ – Mr.Wizard Jun 24 '15 at 10:00
  • 1
    $\begingroup$ You mean a frame around the whole figure? Use Framed in that case. Or do you mean you want a thick edge around the arrow head? EdgeForm should work but you might want to remove the filling of the polygon to see it; use FaceForm[] for that. $\endgroup$ – Sjoerd C. de Vries Jul 1 '15 at 9:33
  • 1
    $\begingroup$ @Mencia Please read this. $\endgroup$ – Mr.Wizard Jul 1 '15 at 10:24
2
$\begingroup$

How about Chop-ing the Arrowheads size to zero below a certain threshold?

{Arrowheads[Chop[Norm@#2/0.0001, 1/100]], Arrow[{#1, #1 + #2}]} & @@@ listb
$\endgroup$
  • $\begingroup$ By changing the size of the arrowheads: a = 10^-8; listb = {{{0, 0}, {2.1*a, -2.1*a}}, {{1, 0}, {2.1*a, 2.1*a}}}; Graphics[{Arrowheads[Norm@#2/0.000001], Arrow[{#1, #1 + #2}]} & @@@ listb] . Can you see how there is some dot/cross at the end of the arrowhead? That's the thing I want to get rid of . $\endgroup$ – Mencia Jun 24 '15 at 10:53
  • 1
    $\begingroup$ @Mencia Yes, but using Chop with the appropriate threshold solves that problem. Are you having trouble applying this? $\endgroup$ – Mr.Wizard Jun 24 '15 at 11:12
  • $\begingroup$ @ Mr.Wizard♦ thank you very much. Your solution works as well as the other one. I happened to try the other one first. $\endgroup$ – Mencia Jun 24 '15 at 11:19
  • $\begingroup$ @Mencia No problem; just curious. $\endgroup$ – Mr.Wizard Jun 24 '15 at 11:33

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.