Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem with ParametricPlot3D in Mathematica

  1. Feb 7, 2012 #1
    I'm having an output quality problem with ParametricPlot3D in Mathematica 7.

    I need to show a complicated curve found by numerical integration of a differential equation (using NDSolve), and export the curve's graphic (from ParametricPlot3D) to PDF, so I can use it in another application. I know how to do it, and it's working, but the curve is having a very crude aspect (straight lines, instead of a smooth curve, or some parts of the curve aren't right).

    Of course, I could add the option PlotPoints-> 5000 to smooth the curve (4000 or less isn't enough, apparently), but this gives a huge PDF file (about 10 MB for a simple vectorial graphic), and it's useless for what I need to do with it.

    The exact same code in Mathematica 4 (which I don't have access anymore) didn't gave me the problem at all : I got a nicely looking curve which could be exported into a small PDF file. So I don't understand what is happening here with Mathematica 7.

    Do I need to add some special directives to the ParametricPlot3D, to get an optimised smooth curve, without having to add something like PlotPoints -> 5000 ?
  2. jcsd
  3. Feb 9, 2012 #2
    Instead of PlotPoints-> 5000 try MaxRecursion->somenumber, and without your curve I can't even guess where you might start. The default for MaxRecursion is Automatic and it appears that some part of your curve is sufficiently convoluted that it bails out before getting the detail you want.

    MaxRecursion should enable it to spend more work on the convoluted parts without needing to have vast numbers of points on the smooth parts. Look up MaxRecursion in the help system and in ParametricPlot3D to get limited information on how this works. Start slowly and see how it behaves as you increment it.

    You can also turn on informative messages about it not being able to achieve sufficient smoothness with On[ParametricPlot3d:accbend]. This can give you some idea when it cannot accomplish what it thinks you are asking for.
  4. Feb 10, 2012 #3
    Thanks, this may help.

    I already used the MaxRecursion option however. It helps in some cases, but not always.
  5. Feb 10, 2012 #4
    Fiddle with the interaction between PlotPoints and MaxRecursion, with the message turned on to see when it believes it cannot find a smooth enough curve and see if you can find an acceptable setting. Choose small specific complicated parts of your curve and watch how those two options interact. PlotPoints should give fixed spacing between the points, no matter how smooth or complicated the curve is at some position. MaxRecursion should enable more or less subdivision between points, more near positions where the curve is complicated.

    A completely different approach, I vaguely recall a pdf-optimizer that would eat a large inefficient pdf and emit a very similar appearing but far smaller pdf, but that was many many years ago and I may be incorrect.

    Or I suppose you could consider writing code that would generate exactly the curve you desire, based on your knowledge of the curve and the demands you have.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook