Mathematica How Can I Adjust X-Axis Intervals in Mathematica's Direction Field Plot?

  • Thread starter Thread starter *best&sweetest*
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
To adjust the x-axis intervals in Mathematica's direction field plot, users can modify the arrow density to enhance detail in specific regions, such as between 0 and 1. Suggestions include decreasing the HeadWidth option for more arrows or using a "picture within a picture" approach to overlay a detailed plot from 0 to 1 on a broader plot from 0 to 30. Alternatively, creating a customized PlotVectorField function with a density input can provide greater control over arrow distribution. The built-in PlotVectorField may not offer sufficient flexibility for detailed visualizations. Implementing these strategies can improve the clarity of the direction field plot.
*best&sweetest*
Messages
36
Reaction score
0
I need to construct a direction field plot for a differential equation and I have this code

Needs["Graphics`PlotField`"];
PlotDirectionField[ff_, {x_, a_, b_}, {y_, c_, d_}] := Module[{f}, f = \
Compile[{x, y}, ff]; PlotVectorField[{190, f[x, y]}, {x, a, b}, {y, c,
d}, ScaleFunction -> (1 &), Axes -> True, Ticks -> None, Frame -> True,
AspectRatio -> 1] ];

and after that I plot the field entering the following code
PlotDirectionField[f[x,y], {x,a,b}, {y,c,d}]
where f[x,y] is the right hand side of my equation.

My problem is that I need to show field for x in quite big interval (from 0 to 30 - a=0,b=30) and I know that the solution curve behaves differently between 0 and 1 than what the field shows. How can I make the plot so that on the x-axis I have intervals of, let's say, 0.1 instead of 1 all the way between 0 and 30?:confused:

Thanks for help!
 
Physics news on Phys.org
First of all, I don't understand why you use a module to compile the function. All plot functions in mathematica automatically compile their arguments.

It sounds like you are not getting enough detail in the arrows, that you want there to be more arrows in the region 0 to 1. First try decreasing the HeadWidth option. If this is not sufficient, I see the following choices:

1) Picture within a picture, i.e. you Show a plot from 0 to 1 superimposed on the plot from 0 to 30, so that there is a higher density of arrows from 0 to 1.

2) Using the Arrow package, create your own customized PlotVectorField function that allows the user to input a density function which gives the densities of the arrows.

Sorry I do not know a simpler way! In my experience, the built in PlotVectorField is not very robust.
 

Similar threads

Replies
1
Views
2K
Replies
1
Views
2K
Replies
2
Views
1K
Replies
1
Views
2K
Back
Top