Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm looking to visualize slope fields of differential equations for my differential equations course. Every example I see draws them as vectors, adding unnecessary "arrows" that, to me, are visually distracting. Is there a way to plot these slope fields without the "arrows" that get in the way?

share|improve this question
    
LineIntegralConvolutionPlot[{y, x - x^3 - 0.3 y + 0.5 Cos[3.125]}, {x, -2.5, 2.5}, {y, -2.5, 2.5}, ColorFunction -> ColorData["DeepSeaColors"], StreamPoints -> 10, StreamStyle -> {"Line", Thick, White}] –  Sektor Mar 5 at 21:28
    
possible duplicate of Visualizing a Complex Vector Field near Poles –  m_goldberg Mar 5 at 22:22

2 Answers 2

up vote 7 down vote accepted

You can use the options VectorScale and VectorStyle of VectorPlot. To create the slope field for the first order equation $y'=f(x,y)$, I usually do something like so.

f = Exp[-x] - y;
VectorPlot[{1, f}, {x, -2, 2}, {y, -2, 2},
  VectorScale -> {0.03, Automatic, None},
  VectorStyle -> {Gray, Arrowheads[0]}]

enter image description here

share|improve this answer

Yes, you can simply replace each occurrence of Arrow with Line like this:

VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}] /. Arrow -> Line

lines

To understand how this works, please read the documentation for ReplaceAll and also take a look at FullForm[VectorPlot[...]]. The point is to see that the plot is just a bunch of graphics directives and therefore we can modify it. Replacing Arrow with Line works because the argument is the same to both Arrow and Line.

You can also achieve it like this:

VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}, VectorStyle -> "Segment"]

Look at the documentation for VectorStyle and especially the part under "Details" to see the full set of options. As a beginner, this is the way to go, and I should probably have used it as well. But as you get more experienced sometimes you don't want to dig in the documentation so you do something quick and dirty like what I did above. It's often useful to be able to, so I'll let the other solution remain in my answer.

My example above was poor, it appears, since it's not a proper slope field. For that part of the question check out Mark McClure's answer.

share|improve this answer
    
+1 for the VectorStyle->"Segment", which I didn't know. Not actually a slope field, however. –  Mark McClure Mar 5 at 21:48
    
@MarkMcClure Thanks for pointing it out, I gave your post a +1 and added a comment about. –  Pickett Mar 5 at 22:35
    
Well, "slightly off" would be a better description than "poor". :) –  Mark McClure Mar 6 at 0:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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