14
$\begingroup$

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

$\endgroup$
6
  • $\begingroup$ You might be referring to CDFs. Look in the docs under howto/CreateAComputableDocumentFormatFile. $\endgroup$ Commented Aug 27, 2015 at 15:56
  • 2
    $\begingroup$ …or are you asking how to make plots act like pop-ups? $\endgroup$ Commented Aug 27, 2015 at 16:21
  • 1
    $\begingroup$ @J. M., Yes, plot act like popups. Patrick, Not sure what's the point of CDF? CDF for each detached plot? $\endgroup$
    – den.run.ai
    Commented Aug 27, 2015 at 16:25
  • 1
    $\begingroup$ Could 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. $\endgroup$
    – MarcoB
    Commented Aug 27, 2015 at 16:29
  • 1
    $\begingroup$ Somewhat related: (70185) $\endgroup$
    – Mr.Wizard
    Commented Sep 22, 2015 at 14:42

2 Answers 2

24
$\begingroup$

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.

$\endgroup$
10
  • $\begingroup$ What interactivity do you mean? $\endgroup$
    – den.run.ai
    Commented Aug 28, 2015 at 2:56
  • 2
    $\begingroup$ I mean, the 3D graphics in the popup can still be rotated, zoomed into, etc. $\endgroup$ Commented Aug 28, 2015 at 3:12
  • 2
    $\begingroup$ Here 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) $\endgroup$
    – Szabolcs
    Commented Aug 28, 2015 at 12:10
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Aug 28, 2015 at 12:16
  • 1
    $\begingroup$ Yeah, but we mostly did DisplayFunction->Identity and DisplayFunction->$DisplayFunction. $\endgroup$ Commented Aug 28, 2015 at 14:19
18
$\begingroup$

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.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.