I'm constructing a single contour showing the points in a plane that satisfy a function. The general form is

ContourPlot[f[x, y] == 0, {x, 0, .5}, {y, 0.2, .5}]

The function f is an explicit but complicated formula that was generated from operations involving analytic integration and differentiation applied to a large algebraic function. It evaluates quite rapidly though, given values of its arguments.

My problem is that the plot takes an unduly long time to generate, perhaps 5 to 10 minutes. Also, and this may be related, the graphic object that it produces has a very large amount of data associated with it -- if I copy it as text and paste it into Word, it exceeds 10,000 pages! The text looks like it is describing how the function is evaluated (it includes function calls that are part of the definition of f), rather than a simple list of data points and formatting information. If I try to Show the output, to combine it with other graphics, it takes a long time to generate, as if it is recomputing the graph again. Also, I get a "Reformatting notebook" message any time I touch the object (e.g., to select it), and this takes maybe 15 or 20 seconds to go away. The plot itself isn't particularly complicated:

contour plot

I can make a ContourPlot of a simple function (e.g., x^2+y^2==1) and it plots quickly, and cut/paste it as text into Word occupies less than two pages.

  • 3
    $\begingroup$ Perhaps the issue depends on f, then? I'm not sure how someone can help without f. Perhaps ListContourPlot? Welcome to mathematica.stackexchange, btw. $\endgroup$
    – Michael E2
    Sep 5, 2014 at 1:28
  • $\begingroup$ Does it help if you add Evaluated -> True to the plot, or if you define g[x_, y_] = Simplify[f[x, y]] and plot it instead? (Note, that's =, not :=.) $\endgroup$
    – user484
    Sep 5, 2014 at 1:55
  • $\begingroup$ Thanks for the quick response. Sorry I can't provide more detail about the function. Basically it's a very large algebraic function of x and y. I'm particularly puzzled by why the graphic comes out as much more than the data and formatting. I tried Rahul's suggestions (though I didn't wait for Simplify to finish, and just used assignment of f to g). Neither that nor Evaluated->True helped. I've now turned to ListContourPlot and I think that will work for me. I can make a grid of values sufficiently quickly and the ListContour provides a good representation of the contour I want. $\endgroup$
    – Dave
    Sep 5, 2014 at 3:03
  • 2
    $\begingroup$ This question appears to be off-topic because the OP asserts he can not provide information critical to working out an answer. $\endgroup$
    – m_goldberg
    Sep 5, 2014 at 10:35
  • $\begingroup$ I'm not sure what other information is needed. It is a very large algebraic function. It returns a real when reals are entered to it from the relevant domain. I don't understand how that detail would affect what is happening. Maybe by answering that I'd better understand what to look for to solve my problem. ContourPlot produces a correct contour for this function, so something is working correctly. I was hoping with this question to get insight into how Mma represents graphics, and what would cause it to represent it in terms of anything but the computed data and the associated formatting $\endgroup$
    – Dave
    Sep 5, 2014 at 11:46

1 Answer 1


I have a guess: ContourPlot is storing your unwieldy function as a Tooltip. You can turn that off with ContourLabels -> None:

ContourPlot[f[x, y] == 0, {x, 0, .5}, {y, 0.2, .5}, ContourLabels -> None]

Update: Sufficient information?

There are these clues, including my own experience of ContourPlot:

  1. The function expression is extremely large. (OP)

  2. The function expression appears in the graphics code when pasted into Word. (OP)

  3. Simple function plots work fine. (OP)

  4. ContourPlot produces a Tooltip, which requires CPU time whenever the mouse passes over the curve. (Me)

  5. I have had the front end tied up by extremely long tooltip messages, frequently accompanied by a "Reformatting notebook" message. (Me)

These I think point strongly to the solution above. The other bit of evidence about Show was difficult to weigh without having the complete code to investigate. It is consistent with the typesetting of the tooltip taking a long time, but I do not know if that happens when the graphics are displayed; it might only happen when the tooltip is displayed. It seemed less likely that the OP's f was doing something odd, given the OP's description of the function.

  • 1
    $\begingroup$ That's it!! I added the option you suggest, and now it produces a graphic object that is quite reasonable. When I copy it as text it is less than 4 Word pages, rather than 10,000+. I can also use it with Show to merge it with other graphs. Thank you very much!! $\endgroup$
    – Dave
    Sep 6, 2014 at 2:31
  • $\begingroup$ @Dave You're welcome. :) $\endgroup$
    – Michael E2
    Sep 7, 2014 at 18:03
  • $\begingroup$ Nice work debugging, and I think your sleuthing makes this question worthy of reopening as it should be of some value to future visitors. +1 $\endgroup$ Sep 7, 2014 at 18:21
  • $\begingroup$ Thanks all for your patience and perseverance with my question. In the future I'll make sure to pose my question in a way that allows others to reproduce it fully. I didn't think that possible in this case, given that it involved a function too large to post. On further thought I realize I could have set up a trial function of comparable complexity that is defined by the manipulations that produce it, in lieu of a verbatim copy of the function itself. Again, thanks everyone, and particularly @MichaelE2, for your expert assistance. $\endgroup$
    – Dave
    Sep 7, 2014 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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