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$

2 Answers 2

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$
10
  • $\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
    Commented Jun 24, 2015 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$ Commented Jun 24, 2015 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
    Commented Jun 24, 2015 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$ Commented Jul 1, 2015 at 9:33
  • 1
    $\begingroup$ @Mencia Please read this. $\endgroup$
    – Mr.Wizard
    Commented Jul 1, 2015 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$
4
  • $\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
    Commented Jun 24, 2015 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
    Commented Jun 24, 2015 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
    Commented Jun 24, 2015 at 11:19
  • $\begingroup$ @Mencia No problem; just curious. $\endgroup$
    – Mr.Wizard
    Commented Jun 24, 2015 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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