Consider that we have some plot in Mathematica notebook, like an ordinary plot = Plot[f[x],{x,xmin,xmax},PlotRange->All,PlotLegends->...]
. Next, assume that f[x]
has been forgotten by Mathematica (like, a part of the code has been deleted, or "Quit kernel" has been applied). Is it possible to extract f[x]
from plot
, i.e. is there some operation that allows obtaining f[x]
by applying some operation with plot
?
$\begingroup$
$\endgroup$
4
1 Answer
$\begingroup$
$\endgroup$
For Example:
plot = Plot[{x^2 - 1/4 x^3, x Sin[x]}, {x, 0, 10}, PlotRange -> All, PlotLegends -> "Expressions"]
points = Cases[plot, Line[linedata_] -> linedata, Infinity];
FindFormula[#, x, 1] & /@ points
Out={1. x^2. - 0.25 x^3., x Sin[x]}
plot//InputForm
(orFullForm
- and you can do it to the image stored in a notebook as well) you’ll get a giant output, but you’ll be able to see the actual code held by Mathematica. Generally, it’s full of line objects ofGraphicsComplex
which all have numerical data. If you had a hint on what the original function was, you might be able to fit it to the data stored there, but I don’t think you can recover the function perfectly. $\endgroup$Plot
stored in notebook is a postscript-like object, i.e. there are a lot of coordinates of points and curves but there is not an original function behind them $\endgroup$