Message Boards Message Boards

Code from drawings


After drawing with the Control D tool, can I recover Mathematica code for my drawing? Otherwise, I have to cut and paste a matrix full of graphic elements into these axes and labels I have drawn. This is a repetitive process producing many similar matrices all with the same set of axes.

Don't use the figure! Full of mutations.


POSTED BY: Douglas Youvan
4 years ago

Yes. After you have created your graphic using the drawing tools, assign the graphic to a parameter, say myGraph by typing myGraph in front of it:

enter image description here

then execute the cell. In a separate cell execute


and you will get the code for myGraph. E.g.:

In[2]:= InputForm[graph]

Graphics[{{AbsoluteThickness[1], StrokeForm[{GrayLevel[0.], Opacity[1.]}], 
   EdgeForm[None], Line[{{0.19861111111111115, 0.49583333333333335}, {0.540277777777778, 
    0.7430555555555556}}]}, {AbsoluteThickness[1], 
   StrokeForm[{GrayLevel[0.], Opacity[1.]}], EdgeForm[None], 
   Circle[{0.6902777777777779, 0.5597222222222222}, {0.3555555555555555, 
     0.2583333333333335}]}}, ContentSelectable -> True, 
 ImagePadding -> {{0., 0.}, {0., 0.}}, ImageSize -> {480, 360}, 
 PlotRange -> {{0., 1.3333333333333335}, {0., 1.}}, PlotRangePadding -> Automatic]
POSTED BY: David Reiss
4 years ago


My gosh! Thank you.

I have this bad habit of "doing" then reading.

Maybe Wolfram should have a button that says "CODE" in the drawing tool for people like me.


POSTED BY: Douglas Youvan
4 years ago

Group Abstract Group Abstract