Creating "detached" plots

14

10

Is it possible to create detached interactive plots in Mathematica like those in MATLAB, Jupyter (IPython), etc. rather than inline ones?

This is an interactive GIF from Rodeo IDE for Python as an example, click on it if it is not giffy. It is quite long animation.

example from Rodeo IDE

denfromufa

Posted 2015-08-27T15:51:37.317

Reputation: 922

You might be referring to CDFs. Look in the docs under howto/CreateAComputableDocumentFormatFile. – Patrick Stevens – 2015-08-27T15:56:18.993

2…or are you asking how to make plots act like pop-ups? – J. M.'s ennui – 2015-08-27T16:21:27.970

1@J. M., Yes, plot act like popups. Patrick, Not sure what's the point of CDF? CDF for each detached plot? – denfromufa – 2015-08-27T16:25:50.440

1Could you add a screenshot of what you want to obtain, e.g. a result from one of those programs you mention? It may make it easier to answer your question if we know exactly what you are after. – MarcoB – 2015-08-27T16:29:32.167

@MarcoB, I inserted one gif example from rodeo ide – denfromufa – 2015-08-27T16:51:43.893

1

Somewhat related: (70185)

– Mr.Wizard – 2015-09-22T14:42:36.583

Answers

24

If you are serious about using this extensively, consider making a function based on CreateDocument...

Here is one way to pursue Szabolcs's line of thought. What follows is a function based on CreateDocument[] that can be used in conjunction with the (now somewhat neglected) option DisplayFunction, which handles where the output of graphics functions should be shown.

First, the custom display function:

popup[gr_] := CreateDocument[gr, "CellInsertionPointCell" -> Cell[], 
                             ShowCellBracket -> False, WindowElements -> {}, 
                             WindowFrame -> "Generic", WindowSize -> All,
                             WindowTitle -> None, WindowToolbars -> {}]

(thanks to Oleksandr for "CellInsertionPointCell".)

Using it is now as simple as

Plot[Sin[x], {x, 0, 2 π}, DisplayFunction -> popup]

which should yield a small window like this on Linux:

popup plot in Linux

or this on Windows (thanks to belisarius):

popup plot in Windows

or this on Mac OS X (thanks to Jens):

popup plot in Mac OS X

It will also work with 3D graphics, and will of course retain the interactivity.


A variation proposed by Szabolcs uses DocumentNotebook[] instead of CreateDocument[]:

popup[gr_] := DocumentNotebook[gr, "CellInsertionPointCell" -> Cell[], 
                               ShowCellBracket -> False, WindowElements -> {}, 
                               WindowFrame -> "Generic", WindowSize -> All,
                               WindowTitle -> None, WindowToolbars -> {}]

This produces a cell that is a mini-notebook of sorts, with a button that yields a popup version of the plot if pressed.

J. M.'s ennui

Posted 2015-08-27T15:51:37.317

Reputation: 115 520

What interactivity do you mean? – denfromufa – 2015-08-28T02:56:47.050

2I mean, the 3D graphics in the popup can still be rotated, zoomed into, etc. – J. M.'s ennui – 2015-08-28T03:12:56.643

2Here are some comments/suggestions: 1, WindowFrame -> "ThinFrame" has no title bar and its not closeable or movable on OS X. 2, 3D graphics can't easily be rotated without SphericalRegion -> True or RotationAction -> "Clip". 3, You could also set $DisplayFunction globally. (But non-plotting functions don't apply DisplayFunction without Show) 4, I really like DocumentNotebook instead of CreateDocument here because it doesn't pop out the window immediately but it does give a popout button. (@denfromufa) – Szabolcs – 2015-08-28T12:10:02.600

1@Szabolcs. 1. I explicitly set WindowTitle -> None since I wasn't sure how to name the popup, and leaving it as "Untitled-n" seemed unseemly. What do you suggest as a replacement for WindowFrame -> "ThinFrame"? 2. I guess I can do special processing for Graphics3D[] arguments. 4. I'll try that alternate; however, if memory serves, MATLAB just pops out the plot at once, and I'd thought the OP would want something like it. – J. M.'s ennui – 2015-08-28T12:16:14.537

cool, but you need to have it appear behind all my other windows for a true matlab-like experience. ("ThinFrame" makes a window you cant get rid of on windows too, btw ) – george2079 – 2015-08-28T13:50:19.627

@george, hah, don't remember MATLAB doing that, but it's been ages since I used it... :) – J. M.'s ennui – 2015-08-28T13:52:13.583

@Sjoerd, I'd credit that to being well-versed with DisplayFunction gymnastics back in the days of old Mathematica. :) – J. M.'s ennui – 2015-08-28T14:09:01.733

1Yeah, but we mostly did DisplayFunction->Identity and DisplayFunction->$DisplayFunction. – Sjoerd C. de Vries – 2015-08-28T14:19:23.690

@J. M. is away, I would like to ask how to apply this method to non-graphics object? I have a "plot" generated using Column[{Overlay[{plot11, plot1}], Overlay[{plot22, plot2}]}, Spacings -> 0]. But DisplayFunctionis an option for graphics and sound functions. I tried GraphicColumn. But because of the problem mentioned [here] (https://stackoverflow.com/a/5708788/4336241), I cannot get it done. Could you please give me some suggestion? Thanks.

– Bemtevi77 – 2019-04-28T16:11:06.173

What about killing the last window that was created, or reploting it? If you run the function again it will open a new window instead of updating the last one. – A. Vieira – 2020-02-12T08:54:34.480

18

You can always create a new notebook and put things in it. If you are serious about using this extensively, consider making a function based on CreateDocument that sets the appropriate options for the notebook to look good.

Check what CreateDocument@Plot[Sin[x],{x,0,10}] does.

Or use a quick-and-dirty hack based on CreatePalette:

fig = CreatePalette[#, Background -> White, Saveable -> False] &

fig@MandelbrotSetPlot[]

You could also use PaletteNotebook instead of CreateDocument. This won't pop out the palette, it just adds a button to do it manually.

Szabolcs

Posted 2015-08-27T15:51:37.317

Reputation: 213 047