# Display a part of a notebook when MMA has done evaluating it

When you evaluate a notebook, it begins to slide upward and shows you a different part of your code, several cells upstream of the notebook...

I was wondering if there is a command that could always show a particular line or a plot which interests me ? For example, if I am solving a differential equation, I'd like to see the plot automatically without having to scroll down and look for my plot...

First World Problem, I know, but I still would like to know if that is possible.

Thx !

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Jun 3 '15 at 14:29
• CellTags, perhaps? Or do you want to find the last output cell generated? (Obviously, there has to be some identifier, since Mathematica can't read minds yet.) – Michael E2 Jun 3 '15 at 15:08
• Somewhat related: (1948) – Mr.Wizard Jun 3 '15 at 17:01

I'm just becoming interested in these sorts of things, so I'm curious to see what other people suggest, but you should look at cell tags. A simple implementation might be a function like this:

interestingCell[x_] := (
CellPrint[
Cell[BoxData@ToBoxes@x, "Output", CellTags -> {"Interesting"}]
]
SetSelectedNotebook[EvaluationNotebook[]];
NotebookLocate["Interesting"]
)


If you then make a plot you want to see you can do:

GraphicsColumn[Plot[x^#, {x, 0, 1},ImageSize->400] & /@ Range[1, 10]]
interestingCell@Plot[Sin[x], {x, 0, 2 \[Pi]}]
GraphicsColumn[Plot[x^#, {x, 0, 1},ImageSize->400] & /@ Range[1, 10]]


Which will focus on the cell tagged interesting. With the caveat that it will only scroll to the first instance of the tag. Obviously if you have more than one interesting plot you can only reliably scroll to one at a time.

• Nice idea. I believe this could also be combined with DisplayFunction if desired. – Mr.Wizard Jun 3 '15 at 17:51

For example, if I am solving a differential equation, I'd like to see the plot automatically without having to scroll down and look for my plot...

How about echoing the plot to a new window?

echoToPopup =
(CreatePalette[#,
Saveable -> False,
WindowMargins -> Automatic,
Background -> None];
#) &;


Now:

Plot[Sin[x], {x, 0, 10}]
2 + 2
PolarPlot[Sin[3 t], {t, 0, Pi}] // echoToPopup
Array[Fibonacci, 5]


This pops the polar plot into a new window but leaves a copy in context in the original Notebook.

You can apply this to all plots of a particular type by setting the DisplayFunction option:

SetOptions[PolarPlot, DisplayFunction -> echoToPopup];


After some digging in the help of MMA, I found what I was looking for, more or less. It is easier than your solutions, but it is not really elegant.

First, just before the cell which contains what interests you, a plot, say, write this :

CellPrint[TextCell["some text","Text",CellTags->"MyTag"]]
Plot[Sin[x],{x,0,1}]


And at the very end of your code, write :

NotebookLocate["MyTag"]


MMA will go at the text cell at the end of the evaluation. Your plot being just under, you will see it at the same time. A better way would be to tag the cell which contains the plot, or whatever it contains...

By the way, what does #, & alone (like &;), the @ in Cell[BoxData@ToBoxes@x and the \@ ?

• The myriad special characters used in Mathematica are described here. – bbgodfrey Jun 3 '15 at 20:45