Writing a graphic to a notebook, cont
- To: mathgroup at smc.vnet.net
- Subject: [mg104665] Writing a graphic to a notebook, cont
- From: Gerry Flanagan <flanagan at materials-sciences.com>
- Date: Fri, 6 Nov 2009 05:16:54 -0500 (EST)
As usual, I found the work around a few minutes after posting. I guess
the right way is to build all the cells first, then create the document
in one shot using CreateDocument. I was trying to create a document,
then write to it cell by cell. Should work, and I still don't understand
why it doesn't, but CreateDocument combined with ExpressionCell does
what I want.
GF
How do you send a graphic to a notebook under program control? For
example, taking the documentation example
CellPrint[Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]], "Output"]]
and changing to
NotebookWrite[nb, Cell[BoxData[ToBoxes[Plot[Sin[x], {x, -2, 2}]]],
"Output"]]
gives an error message (nb is a previously created notebook object).
I think I've seen this somewhere, and remember it was pretty obscure.
Surprising that anything to works inside CellPrint would not work inside
NotebookWrite.
Gerry F.