I want to write a function, highlight — select — it, and then have a button which plots this function. I have tried
PasteButton["Plot", Plot[\[SelectionPlaceholder]], {x, 0, 10}]]
but it does not do the work.
Any idea ?
I want to write a function, highlight — select — it, and then have a button which plots this function. I have tried
PasteButton["Plot", Plot[\[SelectionPlaceholder]], {x, 0, 10}]]
but it does not do the work.
Any idea ?
For readers information, cross posted and answered on Mathematica.SE:
How to paste an equation to a graphics
In case you want to plot in place you can use something like:
Button["Plot",
NotebookWrite[
InputNotebook[],
ToBoxes @ Plot[
Evaluate @ ToExpression @ CurrentValue @ "SelectionData",
{x, 0, 10}
]
]
]
You may want to add Method -> "Queued" for more complicated plot to avoid timeout.
And if you want x from the selection to be scoped properly, e.g. to give a plot even if x already has a value, then wrap the procedure inside the Button with Block[{x},...].
Thanks I think it was not a trivial question