2

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 !

Darryl
  • 21
  • 1

3 Answers3

1

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.

N.J.Evans
  • 5,093
  • 19
  • 25
1

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];
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
0

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 \@ ?

Darryl
  • 1