# Tag Info

112

Completely redesigned at 2015 12 19! Simplified interface, more functionality, robust performance. Plots can now be easily uploaded to StackExchange from within PlotExplorer thanks to halirutan! Code is at end of post. Functionality: Works with any graphics object, plots, charts, etc. (e.g. Plot, ListPlot, ArrayPlot, RegionPlot, GeoGraphics, BarChart, ...

36

In addition to István's fine answer, there is also ExperimentalExplore[] which provides almost all the functionalities in his PlotExplorer. I think it was Szabolcs who first told me of this function. If you call the above function with no arguments, you can choose to interactively work with either Plot, ParametricPlot, Manipulate or Graphics. Alternately, ...

27

One of the excellent places to look is the Wolfram Demonstration Project. There are many cases with custom controls there. You can test out controls immediately and download the source code. Because I know that site pretty well I will keep the list here. Relief-Shaded Elevation Map 3D Waves Potter's Wheel Motion Blur Contours of Algebraic ...

23

Edit: getting rid of FilledCurve to speed things up. Here's something fun: g = Normal @ Show @ CommunityGraphPlot[ ExampleData[{"NetworkGraph", "DolphinSocialNetwork"}] ]; dist = Normalize[#] (2./Pi ArcTan[Norm[5 #]]) &; DynamicModule[{drag,pts,prims} , pts = Union@Cases[g, {_?NumericQ, _?NumericQ}, \[Infinity]]; prims = ( First[g] /...

22

I have finished a project where widgets like this have been useful so I thought I would share. By combining InputField and PopupMenu a searchable popup selection table can be created. searchPopup[Dynamic[selection_], list_List] := DynamicModule[{x = ""}, Grid[{{ InputField[Dynamic[x], String, Appearance -> "Frameless", ...

21

Don't forget, with M we have all of Java at our fingertips with just a few keystrokes. So why don't you use Java Swing, which is a professional UI framework that runs on hundreds of millions of devices. I have ShowProgressBar and DestroyProgressBar in my init.m, because I use them frequently. Needs["JLink"] ReinstallJava[] ShowProgressBar[title_String:...

21

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 ...

20

You can do this using Show and PlotRange which can be used in combination with graphs. To determine the full PlotRange of the original Graph you could use AbsoluteOptions to determine the values of the VertexCoordinates of the graph. The function CoordinateBoundingBox, introduced in V10.1, is helpful here: SeedRandom[1110]; g = RandomGraph[{70, 200}] {...

18

If you're on version 9, you can use gauges: HorizontalGauge[90, {0, 100}, ScaleRangeStyle -> Red, GaugeMarkers -> "ScaleRange"] I don't fully understand how Mathematica scales and aligns things like gauges (and it's not the sort of thing that's easy to find in the documentation) but I would explore the options using a Manipulate: Manipulate[ ...

18

In this case I don't know how to post something helpful without providing full code so I'll just do that and hope this wasn't homework. My emphasis is on clarity (hopefully) rather than brevity or peak efficiency. flip = # /. {LightRed -> LightBlue, LightBlue -> LightRed} &; flipNeighbors[i_, j_] := (color[##] = flip @ color[##];) & @@@ ...

17

You could do create a simple graph editing tool to create a graph from scratch by doing something like this. To add edges you just click and drag. DynamicModule[{pt1, pt2, ind1, ind2, pts = {}, edges = {}, cedge = {}}, Manipulate[ EventHandler[ Dynamic@Graphics[ {Line[pts[[#]] & /@ edges], cedge, {Red, PointSize[Medium], Point[pts]}}, ...

17

I know of no method by which to control the color of that element. I'm afraid that it may not be possible. I believe the style of the ProgressIndicator is taken from the OS settings, or rather the ProgressIndicator is rendered by the OS. If you look at the on-line documentation for versions 7, 8, 9 you see that the style changes: 7: 8: 9: Further, I ...

17

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[#, ...

16

Some you can find in the Documentation Center, like the angular slider in Dynamic's documentation (under Applications), or the ValueThumbSlider in the Advanced Manipulate Functionality section (under Custom Control Appearances). Some you can find in developer packages like the angular slider in the "Experimental" package: Needs@"Experimental"; ...

15

Intro One day I was playing with Developer package and found DateSetter which uses some kind of floating elements that I found useful. After taking a look at a source code I found out it was FrontEndAttachedCell. From the code one could learn enough to create something useful: Usage FrontEndAttachCell[ parentObject, (*Box or Cell ...

14

You want to use Grid. Code Panel[ Grid[ { (* The 1st row *) { Row[{"Board size: ", InputField[Dynamic[max], Number, FieldSize -> 3]}], Button["Clear Board", ImageSize -> All] }, (* The 2nd row *) { Graphics[Circle[], ImageSize -> 300], SpanFromLeft } }, Alignment -> {{Left, Right}, Baseline}] ] ...

14

Since Input is a DialogInput, it seemed reasonable to peek into Input's structure to understand how the focus is set. After removing the ReadProtected attribute I've realized that there is no neat way to do it, as WRI itself has done the reposition of the focus via successive SelectionMove calls. This example below is not the original but a modified version,...

14

This is a bit more complicated, but I did this for a human experiment previously, so why not share it. The code keeps track of nodes and edges of a graph that can be manipulated: new edges can be drawn by dragging the mouse from one node to the other edges can be deleted via right-click menu nodes can be moved by dragging while holding Ctrl node can be ...

14

I'll post a function based on the title of the question. You wrap your dynamic code in profileDynamics optionally passing the option "Print"->True (defaults to False). It should be noted that this can only profile the explicit Dynamics that are on the code. Nested dynamics that are generated at runtime are not profiled by this ClearAll[profileDynamics]; ...

14

Based on undocumented FrontEndAttachCell: What is FrontEndAttachedCell? And ExperimentalAutocompletebut this can be replaced with Mike's approach. Need to work on style, automatic scrolling and some edge cases, but already works quite well. Feedback appreciated. Column[{ searchPopup2[Dynamic[selection], list], Graphics@Disk[] }] Code ...

13

This solution relies on putting a TagBox with a custom tag around the part to be replaced, reading the cell and replacing the tag, then writing it back. Personally I've always felt that the need to read the entire cell and write it all again seems kind of clunky, but I don't know of a better way to do this. MakeBoxes[replacementMarker[a_,tag_],StandardForm]^...

12

I think these questions being indeed basic, are rather important. I cannot answer the first two myself, though would love to see some methods that can deal with them. As always, there are other ways to solve the remaining two questions. Since Mathematica is not designed to produce standalone ("executable") files, you need to have either Mathematica or the ...

12

For this solution, I've made rasterized versions of ProgressIndicator, replacing green tones by similarly light/dark red tones by means of a function toRed. All other colors used by default are gray levels, i.e. they match the {c_,c_,c_} pattern. This works fine only for the appearance shown third in Mr. Wizard's answer (also seen below). What's left then is ...

12

I would suggest using the second argument of Dynamic: DynamicModule[{shape = Disk[], targets = RandomPoint[Disk[], 10]}, Panel@Column@{ Item[ RadioButtonBar[Dynamic[ shape, (targets = RandomPoint[#, 10]; shape = #) & ], {Disk[] -> "Disk", Rectangle[] -> "Rectangle"}], Alignment -> Center ], Dynamic@...

12

J. Fultz' answer indicates that it is not a bug but a feature which needs better documentation. Get a habit of defining your procedures with [], e.g. f[]:=Print[1]. (Which creates DownValues instead of OwnValues). DynamicModule saves its variables OwnValues in the first argument of DynamicModule. It which does not support SetDelayed and is sliently ...

11

Try: Button["Select this cell", SelectionMove[ButtonNotebook[], All, EvaluationCell]]

11

You can use a combination of MouseDown and MouseClickCount as in the following examples: example 1: double-click increments the value of j: j = 1; EventHandler[Panel[Dynamic[j]], "MouseDown" :> If[CurrentValue["MouseClickCount"] == 2, ++j]] example 2: double-click toggles the text color: DynamicModule[{col = Green}, EventHandler[ Style["text"...

11

By default, DynamicModule uses SynchronousInitialization -> True. This causes the initialization to be performed on the preemptive link, disabling any updates to the front-end. In particular, print statements, cell creation and dynamic box updates will all be deferred until the initialization completes. If we wish to monitor that initialization within ...

10

If you notice Mathematica Documentation Center search field is kind of the same thing. And search window from Ctrl-F too. It uses a similar concept to what I'll show. Important thing to know is that EventHandler can track commands from the Mathematica menu. There is an undocumented option HandleShiftReturn and here is a trick I learned from FW: ...

10

You can also look at the GUIKit` package which allows you to create complicated widgets and panels that mimic the look and feel of the OS. The user guide/tutorial is pretty decent and has several examples too that you can learn from and modify to your needs. In fact, a lot of the additional editing/explorer functionality like GraphEdit and DatabaseExplorer ...

Only top voted, non community-wiki answers of a minimum length are eligible