Message Boards Message Boards

0
|
8596 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How do you display a graphic in a new window -- repeatedly?

Posted 9 years ago
POSTED BY: David Keith
4 Replies
Posted 5 years ago

Thanks. Could I plot many figures in a new window. In the suggested way the only one figure (the last) is displayed.

POSTED BY: Dmitry Testov

Here's one way to do it: First, create your output window like this:

CreateDocument[Dynamic[theGraphic], WindowSize -> {500, 500}];

CreateDocument has a lot of options (use Options, not all of them are listed in the Documentation article), I just added WindowSize here because you asked about it. Maybe you can set the window position as well, although I can't seem to find it right now. (But that would ensure that the output window can't be moved.)

Anyway, the output window will now update theGraphic dynamically, so you can do this:

theGraphic = ListPlot[RandomReal[{0, 1}, {20, 20}]];

Alternatively, if you want to change the behaviour of all Graphics objects, you could do this:

$Post = (If[TrueQ[Head[#] == Graphics], theGraphic = #;, #] &);

And now an expression like ListPlot[RandomReal[{0, 1}, {20, 20}]] will change theGraphic and therefore trigger an update in your plot window.

I'm not sure if this is what you were looking for... It's a rather clumsy solution but maybe it'll get you started.

POSTED BY: Bianca Eifert
Posted 9 years ago

Thanks, Bianca -- That works!

POSTED BY: David Keith
Posted 9 years ago

Actually there is a straightforward way to change the behavior of all Graphics objects (including those which do not go to the $Output channel): simply to define

$DisplayFunction = ((theGraphic = #; #) &);

An alternative to Dynamic solution is to use the second argument of CreateDocument:

obj = CreateDocument[];
$DisplayFunction = ((CreateDocument[#, obj]; #) &);
Do[ListPlot[Prime[Range[n]], Filling -> Axis], {n, 25, 50}]
POSTED BY: Alexey Popkov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract