Replot Demo

© Yuri E. Kandrashkin (2004)

Installation and Loading

A proper directory path to place the file "replot.m" one can get evaluating the next line:

TableForm[Map[ToFileName[#,"Applications"]&,
{{$TopDirectory,"AddOns"},$UserAddOnsDirectory,$AddOnsDirectory}]]

This loads Replot package

<<Replot`

Demo

Here is a simple command:

Replot[Sin[x],{x,0,2π}]

It opens a new notebook to edit the graphics:

Function Replot will keep evaluating until the notebook "Replot Window" is closed. The notebook will be closed by clicking any of next buttons: "Return Options", "Ok" or "Cancel". "Return Options" returns the list of activated options, "Ok" will plot edited graphics back into a working notebook, and "Cancel" closes the notebook "Replot Window". The notebook may also be closed as usual via FrontEnd menu commands or by clicking on the Close button of the notebook. This is equivalent to "Cancel" command. The notebook "Replot Window" will be automatically closed if there is no button is clicked within approximately 30 seconds after the notebook opened. This property is regulated by Replot option DelayTime.

This notebook includes the editing graphics and panel of buttons to simplify input of most of the options. The options are separated by groups General, Axes, Frame, Epilog and Prolog. PlotStyle and other options corresponded to individual curves collected in buttons from right side. Currently selected group marked like radio button, its options listed below. Initially selected group is "General".

Left mouse button click on the option name activate it, this automatically changes the graphics and show the activated options in bold.

To switch between Rule, "->", and RuleDelayed, ":>", sets of an option click on "->" (or ":>").

To change the option value click on it. This opens a list of its preset values:

Option Frame here has two preset values True and False. To set a new value click on the preset value or type in the framed cell below the option name, Replot uses the value placed in this cell. To apply the chosen value or to close sublist of presets click on the buttons on right side.

Some of options consist of listed structures. For example PlotStyle has color, thickness and dashing directives. They are organized as sub-options:

The panel button traces the changes of the corresponding curve:

By clicking on "Ok" button the edited graphics is drawn into the evaluating notebook and the notebook "Replot Window" is closed.

Replot conserves the template of options applied to previous graphics. The template automatically applied to a new graphics, which is convenient for a series of figures.

Replot[{Sin[x], Cos[x]},{x,0,2π}]

The graphics consists of the template of options used before.

One can activate or deactivate this template options applying the buttons "Activate" and "Deactivate" buttons to each group of options separately:

These buttons may be also used for rollback point for a selected group of options. The option LastTemplate controls if the template from previous plot should be applied to a new graphics.

Scrolling buttons [◂] and [▸] used to edit curves if the number of functions exceeds four.

To plot tabulated functions graphics primitives may be generated as option values of Prolog or Epilog:

Here we changed the preset values, replacing table of random numbers by tabulated values of Sin[x] and Cos[x], and also activated some style options.

Once the last line with "Text" or "Graphics" primitive is activated an extra inactive primitive template appears when the preset option sublist is closed, "Graphics 2" and "Text 2", in the next figure:

Once the graphics is generated by Replot it can be easily re-edit later on. To provide this feature the applied options are stored in the cell with graphics as ButtonBoxOptions->{ButtonData:>{ReplotOptions->{options}}} (use menu Format ⊳ Show Expression to see unformated cell expression). The storage of information about options in the cell options has one drawback. If expressions of one Input cell generate several graphics the option values of the first only graphics will be conserved, when cell expressions would send for evaluation to the Mathematica kernel. So to conserve the option values of a graphics it is desirable using no more than one Replot function in the one Input cell. The used options may be also saved explicitly by "Return Options" button.

Plotting options of a graphics have been generated by Replot can be later derived by placing the following expression just after this graphics. For example, placing the following Input cell after the graphics and evaluating it we get options, used for the graphics:

SelectionMove[EvaluationNotebook[],All,EvaluationCell]
SelectionMove[EvaluationNotebook[],Previous,Cell]
ButtonData/.(ButtonBoxOptions/.Options[NotebookSelection[EvaluationNotebook[]]])
%//FullForm

The first two lines in the Input cell select the previous cell, next two lines return applied options and their FullForm, which is needed for a correct representation of a StyleForm in PlotLabel. To use the resulting options copy and paste them into an editing cell, but don't edit Output cell directly, otherwise the information about functions like StyleForm, HoldForm etc would be lost.

The initial graphics of Replot[funcs, range, opts] depends on the value of option LastTemplate and if it is a new graphics or a graphics generated by Replot before. The sets of options applied to a graphics initially (i.e. when appears the notebook "Replot Window") in the following order are shown in the Table:

({{LastTemplate 
value, Creating
new graphics, Editing 
existing graphics, Comments}, {Automatic, {opts,(Subscript[opts, f])}, {opts,(Subscript[opts, g])}, Default value, applies the last used set of options to a new graphics, 
but doesn't change the existing graphics}, {True, {opts,(Subscript[opts, f])}, {opts,(Subscript[opts, g]),(Subscript[opts, f])}, Applies both templates, the previously used options of a graphics,
and the last used set of options in the current Mathematica session }, {{True,False}, {opts}, {opts,(Subscript[opts, g])}, Ignores the last used template}, {{False,true}, {opts,(Subscript[opts, f])}, {opts,(Subscript[opts, f])}, Ignores the previously used options of graphics}, {False, {opts}, {opts}, The starting graphics uses default Plot options}})

Here (Subscript[opts, f]) is a sequence of options applied finally to the previous graphics in the current Mathematica session, and (Subscript[opts, g]) is the set of options of an existing graphics created by Replot (in the one of the previous sessions or in the current session).

Restrictions and limitations

1) Better not to use more than one Replot function in one Input cell (see above)
2) Replot interferes with the search notebook "Find"