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:

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.
Answer
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:
The function expression is extremely large. (OP)
The function expression appears in the graphics code when pasted into Word. (OP)
Simple function plots work fine. (OP)
ContourPlotproduces aTooltip, which requires CPU time whenever the mouse passes over the curve. (Me)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.
Comments
Post a Comment