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 know that I exported Graphs to PDFs before but it doesn't seem to work any more. I tried

K5 = GraphData[{"Complete", 5}]
Export["K5.PDF", K5]

And I get a PDF with a grey rectangle in it. Even exporting to TIFF doesn't seem to work. When I right click the Graph object I can do a "Convert to Graphics". Then exporting this converted Graph to PDF works.

Why doesn't it work directly? If it's not possible ... How can I convert a Graph to Graphics programatically before calling a export to PDF?

I'm using Mathematica 9.0.0 on Windows 7 x64

UPDATE: Problem solved by Szabolcs I checked if dynamic evaluation was checked and it was. However when I restarted Mathematica it did work as expected. I realize with hindsight that this morning going through some help files a warning was issued about dynamic evaluation. I didn't really pay attention to it but probably it got disabled automatically but did not show that change in the evaluation menu option. Also Show[] is nice to know that it effectively converts the Graph to a non dynamic graphics object!

share|improve this question
    
Which version of Mathematica are you using, and on which operating system? –  Szabolcs Feb 28 '13 at 15:17
    
Try upgrading to 9.0.1 and see if that fixes the problem. –  Szabolcs Feb 28 '13 at 15:40
    
@Szabolcs I updates the question. Thx for the help. Something to keep in mind about this dynamic evaluation! –  Lou Feb 28 '13 at 15:54
add comment

3 Answers 3

up vote 4 down vote accepted

I cannot reproduce this behaviour (it does export correctly here, Mathematica 9.0.1, OS X). But the grey box typically appears when dynamic updating is disabled (check Evaluation -> Dynamic Updating Enabled). Note that graphs are dynamic objects and if you uncheck this menu item, they'll display as grey boxes inside the notebook.

Now why it would happen that inside the notebook you do see the graph, but when you export it turns into a grey rectangle, I do not know. But if you wrap the graph in Show, it'll be converted into a non-dynamic Graphics object, and you should be able to export it (until you figure out why the direct way doesn't work):

Export["K5.pdf", Show[K5]]
share|improve this answer
add comment

I did not get the same behavior either. An alternative to Export would be right click the output cell, and then Save selection as. You may save it as a pdf file or many other formats. The pdf file is different from the exported one. (BTW, when you have overlapping regions with different colors, the exported pdf file don't have the corret behavior, but the saved one do.)

In this way, you get a file with a graph including the text Out[ ]=.To get rid of this, you may paste the resluting graph into a new cell, and then do the above steps.

share|improve this answer
    
Thx I tried doing that (with the right click export as pdf) but that didn't work either. That's why I posted the question. This right click is not an option since I need hundreds of graphs exported and I'm to lazy ;) –  Lou Feb 28 '13 at 15:57
add comment
ToExpression@ToBoxes@K5 // Head
(* Graphics *)
share|improve this answer
    
Show is an easier way to achieve the same, but this should simply not be necessary anyway. –  Szabolcs Feb 28 '13 at 15:15
    
@Szabolcs Yea. Exports fine for me too without converting to Graphics first. –  ssch Feb 28 '13 at 15:24
add comment

Your Answer

 
discard

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.