5
$\begingroup$

I have an output graph on a saved notebook that I cannot reproduce with my data (I messed up the instructions).

Can I take that graph, insert it in a new notebook and modify it? (I'm thinking about axes, labels, fonts, etc.)

$\endgroup$
3
  • $\begingroup$ short answer: yes $\endgroup$
    – chris
    Commented Sep 25, 2012 at 10:13
  • $\begingroup$ !Mathematica graphics $\endgroup$
    – chris
    Commented Sep 25, 2012 at 10:14
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)[Read the FAQs] (tinyurl.com/cacvex2)! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` $\endgroup$ Commented Sep 25, 2012 at 13:23

1 Answer 1

6
$\begingroup$

If you mean "graph" as in "plot of a function", then assign your graph to a variable and then extract/modify its properties. Imagine you have just this:

enter image description here

Then this is an example of "extract/modify its properties":

Show[Graphics[{Red, Thick, pl[[1, 3, 2]]}], Axes -> False, Frame -> True, 
BaseStyle -> {12, FontFamily -> "Times", Italic}, AspectRatio -> .6]

enter image description here

If on other hand you have "graph" as a network, then there are many options to go around, because Graph returns an object where all information about Graph is preserved. This is one way to do it:

enter image description here

Show[AdjacencyGraph[AdjacencyMatrix[gr], 
  AbsoluteOptions[gr, VertexCoordinates], GraphStyle -> "ThickEdge"], 
 Axes -> False, Frame -> True, FrameTicks -> True, 
 BaseStyle -> {12, FontFamily -> "Times", Italic}, AspectRatio -> 1]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ for clarity, once youve closed the nodebook and quit the kernel, to get the plot back as an object you can modify you need to copy the graphic (right click/copy) and past into an input cell, setting equal to a variable. $\endgroup$
    – george2079
    Commented Sep 25, 2012 at 14:55
  • 1
    $\begingroup$ Just a note: such a solution has been possible only since the day (with Version 6??) that graphics output ceased being merely a side-effect of code and became instead an actual Mathematica object capable of being operated upon like any other object. $\endgroup$
    – murray
    Commented Sep 25, 2012 at 20:42
  • $\begingroup$ Yup, I didnt know this till looking at this question.. I guess it would be worthwhile to read those release notes!! $\endgroup$
    – george2079
    Commented Sep 25, 2012 at 21:22

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.