Getting mathematica to take more points when it plots

In summary, the speaker has had trouble with Mathematica plots not using enough points to accurately represent complex functions. They have found that increasing the PlotPoints option can improve the accuracy of the plots, but it also increases the calculation time. They also note that Mathematica may calculate the number of points based on the range of the function rather than the plot range.
  • #1
rynlee
45
0
I've had this problem many times in the past, and haven't thought of a way to fix it.

Sometimes when I plot a function that requires quite a bit of effort on mathematica's part, (for example, one time the function was a sum of about a thousand terms, each of which was multiplied complex terms with my independent variable dependence (in this case time)), when it plots it the plot is correct but for some reason doesn't take enough points, it's not nicely curved as it should be but instead looks like connected line segments. When I have a particularly high frequency plot this is particularly troublesome, as features get washed out sometimes and curves are straightened.

Most recently I am plotting a contour plot where there are oscillations in each of the variables, and mathematica is turning the contour basically into polygons.

Is there a way to get mathematica to use more points when constructing a plot? Is that the source of this grievance?

Thanks for any Advice
 
Physics news on Phys.org
  • #2
For normal plots its PlotPoints->x, for contour I would have to double check (munching on breakfast atm) but it should be in help under options somewhere (if it is not the same as above)
 
  • #3
thanks! that really did the trick, I'm amazed at how few points mathematica actually takes. That said I'm glad for its low plot points by default - cranking it up really increases the calculation time, it looks like when PlotPoints is set to automatic, it tries to keep the calculation time reasonable.
 
  • #4
No worries. Also I've found if you're plotting say an interpolating function which is valid over a given range, it will calculate the number of points to use based on that range rather than the plot range, at least in certain instances.
 
  • #5


There are a few potential solutions to this issue. One option is to use the "PlotPoints" option in Mathematica's Plot function, which allows you to specify the number of points to be used in the plot. Increasing this number may result in a smoother and more accurate plot.

Another option is to use the "MaxRecursion" option, which controls the maximum number of recursive subdivisions used in plotting. Increasing this number can also lead to a more detailed and accurate plot.

Additionally, you may want to consider using a different plotting function, such as ListPlot or ParametricPlot, which may provide better results for your specific function.

It's also important to consider the complexity of your function and the resources available on your computer. If your function is extremely complex, it may be helpful to simplify it or break it down into smaller parts before plotting.

Overall, it's always a good idea to experiment with different options and functions in Mathematica to find the best solution for your specific plot.
 

Related to Getting mathematica to take more points when it plots

What is the default number of points in a plotted Mathematica graph?

The default number of points in a plotted Mathematica graph is approximately 50 points.

Why would I want to increase the number of points in a Mathematica plot?

Increasing the number of points in a Mathematica plot can help to create a smoother and more accurate graph, especially for complex functions or when zooming in on a specific area of the graph.

How can I change the number of points in a Mathematica plot?

To change the number of points in a Mathematica plot, you can use the PlotPoints option in the Plot or ListPlot functions. For example, Plot[Sin[x], {x, 0, 2Pi}, PlotPoints -> 100] will plot the sine function with 100 points.

Is there a limit to how many points I can have in a Mathematica plot?

There is no specific limit to the number of points in a Mathematica plot, but adding too many points can significantly slow down the plotting process.

What other options can I use to improve the quality of a Mathematica plot?

In addition to increasing the number of points, you can also use the MaxRecursion option to refine the plot further. Additionally, you can use the PlotRange option to focus on a specific region of the graph, and the PlotStyle option to change the appearance of the plotted points or lines.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top