Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I've generated a bunch of graphics using ContourPlot wich, given the nature of my problem, take a long time to create, and I was wondering if there is a way to save the object (not the image) to a file so I can retrive it later to manipulate, i.e. use Show, change colors, add text, etc.

For example, suppose I define something like

conic = ContourPlot[x^2/9 + y^2/16, {x, -10, 10}, {y, -10, 10}, 
    ContourStyle -> Red, ContourShading -> None, Contours -> 15, 
    Axes -> True, AxesLabel -> {x, y}]

then by doing


I can see the objetc:

enter image description here

Now, what I'd like to do is save the object in such way that I'll be able to change the color from red to blue, the labels, the aspect ratio, etc. by just importing it and modifying the proper options without having to calculate it again.

I guess a rudimentary solution would be to export the object to a txt file, and later import it, manipulate it and then use ToExpression, but I was wonderign if there is a more "within" approach.

I hope this isn't a duplicate. I've tried to search for the answer but the keywords save and graphics made it impossible.

share|improve this question
it seems you cat do conic>>"afile.m"; and newconic=<<"afile.m". Even more simply, can save the notebook, quit mathematica; open it later and via cut and paste assign it to a new variable; say plot=< your plot > and play with it. Does this answer your question? –  chris Oct 3 '12 at 20:02
I would have accepted it as answer :) +1 to the comment at least. –  Pragabhava Oct 3 '12 at 20:08

2 Answers 2

up vote 4 down vote accepted

You could use Put and Get:

conic = ContourPlot[x^2/9 + y^2/16, {x, -10, 10}, {y, -10, 10}, 
  ContourStyle -> Red, ContourShading -> None, Contours -> 15, 
  Axes -> True, AxesLabel -> {x, y}]

conic >> "conicfile";

(* later... *)

con = << "conicfile";

con /. Red -> Blue
share|improve this answer
I said it first ;-) –  chris Oct 3 '12 at 20:05
Thanks a lot, I knew it was a stupid question! –  Pragabhava Oct 3 '12 at 20:08
There are no stupid questions! I didn't know either (and I always find the non-textual commands (>>, //, :>, [[]], etc.) no be some sort of arcane magic I didn't learn :( –  JorgeGT Oct 4 '12 at 7:29

As far as I know, they're never images in the first place unless you explicitly Rasterize them. When you load the notebook, Mathematica is building it up from the FullForm structure. Open up a Mathematica notebook in Notepad and you'll see that it's just a bunch of Mathematica structure, no images. So Mathematica already does what you expect.

If the object is very large though, one option is Export["c:/myfile.mx", conic] which saves it in a raw Mathematica binary format that you can later read in with conic = Import["c:/myfile.mx"]. I'm not sure this is strictly advantageous, though. Mostly it will help load the object faster.

share|improve this answer
Thats nice to know. The thing is I have hundreds of this "images", so displaying all of them in the notebook is out of the question, but I can easily import them as you suggest. –  Pragabhava Oct 3 '12 at 22:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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