I used Export
because your question said "a button ,,, that would export the data". You didn't mentions Save
.
Save
writes its output to a file as front-end code; i.e., in the same form as if it were stored in an Mathematica notebook file. Export
can write its output in large number of formats. In my code I chose to have it write the Manipulate
expression's plots in PNG format.
It is easy to modify my Button
code to use Save
in place of Export
. Like so:
path = FileNameJoin[{$HomeDirectory, "DeskTop", "plots.wl"}]
Manipulate[
plots =
Panel @
Column[
{Plot[x, {x, 1, 4}, Epilog -> {Line[{{y, 0}, {y, 10}}]}],
Plot[x^z/4^z, {x, 1, 4}, Epilog -> {Line[{{y, 0}, {y, 10}}]}]}],
{plots, None},
{y, 1, 4},
{z, 1, 10, 1},
Row[
{Spacer[140],
Button["Save Plots", Save[path, plots],
Method -> "Queued", ImageSize -> Automatic]}],
TrackedSymbols :> {y, z}]
Notes
- The file path has been changed to give the file the extension
wl
.
- You can retrieve the plots with
Get[path]