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
Click For Summary
SUMMARY

This discussion focuses on adjusting the x-axis intervals in Mathematica's direction field plot for differential equations. The user seeks to visualize a direction field with finer intervals between 0 and 1 while plotting over a larger range from 0 to 30. Key solutions proposed include decreasing the HeadWidth option for arrow density and using a combination of plots to superimpose a higher density plot from 0 to 1 onto the broader plot. Additionally, creating a customized PlotVectorField function with a user-defined density function is suggested for more control over arrow placement.

PREREQUISITES
  • Familiarity with Mathematica's Graphics`PlotField` package
  • Understanding of differential equations and direction fields
  • Knowledge of the PlotVectorField function in Mathematica
  • Basic skills in function compilation using Compile in Mathematica
NEXT STEPS
  • Explore the use of the HeadWidth option in Mathematica's PlotVectorField
  • Research how to implement the Show function for superimposing plots in Mathematica
  • Learn about creating custom functions in Mathematica for enhanced plotting capabilities
  • Investigate the Arrow package in Mathematica for advanced arrow customization
USEFUL FOR

Mathematics educators, students studying differential equations, and Mathematica users looking to enhance their plotting techniques for direction fields.

*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 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 0 ·
Replies
0
Views
675
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K