DocumentTools[Components] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Document Tools : Components : DocumentTools/Components/Plot

DocumentTools[Components]

  

Plot

  

generate XML for a Plot Component

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

Plot( p, opts )

Parameters

p

-

(optional) ; a 2D or 3D plot, or the result from InlinePlot

opts

-

(optional) ; one or more keyword options as described below

Options

• 

captionalignment : identical(center,left,right):=center ; horizontal alignment of the component caption.

• 

captionposition : identical(bottom,top):=bottom ; position of the component caption.

• 

clickaction : string:=""; A string which parses to one or more valid statements in 1D Maple Notation. These statements form the Click Action... Component Code that executes when the Plot is clicked. The default is the empty string (no such action code).

• 

clickdefault : truefalse:=false; Indicates whether the manipulator on a pointer click is to execute action code. The default value is false.

• 

clickx : realcons; The initial x value of the click selector (as if the cursor were clicked).

• 

clicky : realcons; The initial y value of the click selector (as if the cursor were clicked).

• 

continuous : truefalse:=false ; Indicates whether the animation plays continuously or stops after displaying all the frames once.

• 

delay : posint:=100 ; Delay in milliseconds between animation frames. The default value is 100.

• 

dragendaction : string:=""; A string which parses to one or more valid statements in 1D Maple Notation. These statements form the Drag End Action... Component Code that executes when dragging the the pointer over the plot ends. The default is the empty string (no such action code).

• 

drageventaction : string:=""; A string which parses to one or more valid statements in 1D Maple Notation. These statements form the Dragged Action... Component Code that executes when the pointer is dragged over the plot. The default is the empty string (no such action code).

• 

drawcaption : truefalse:=false ; Indicates whether the component caption is shown. The caption on a PlotComponent is distinct from any caption in the contained plot, and is automatically generated by the graphical interface.

• 

enabled : truefalse; Indicates whether the component is enabled. The default is true.

If enabled is false then the inserted component is grayed out and interaction with it cannot be initiated.

• 

endx : realcons:=0.0 ; The initial x value of the drag end selector, (as if a drag had ended).

• 

endy : realcons:=0.0 ; The initial y value of the drag end selector, (as if a drag had ended).

• 

pixelheight : posint; The height in pixels of the component.

• 

fillcolor : {list(nonnegint),symbol,string}:=[255,255,255] ; Specifies the background color of the component. The passed value can be either a named color or a list of three integers each between 0 and 255. A list of nonnegative integers is interpreted as RGB values in a 24bit 3-channel color space. The default value is [255,255,255] which corresponds to white.

• 

hoveraction : string:=""; A string which parses to one or more valid statements in 1D Maple Notation. These statements form the Hover Action... Component Code that executes when the pointer hovers over the plot when in focus, if the component's Manipulator is set to Click and Drag. The default is the empty string (no such action code).

• 

identity : {name,string}; The reference name of the component.

• 

legendvisibility : truefalse ; Indicates whether the legend is visible.

• 

showborders : truefalse; Indicates whether component borders are shown

• 

startx : realcons:=0.0 ; The initial x value of the drag start selector, (as if a drag had occurred).

• 

starty : realcons:=0.0 ; The initial y value of the drag start selector, (as if a drag had occurred).

• 

tooltip : string; The text that appears when the mouse pointer hovers over the component. The default is the empty string (no tooltip).

• 

visible : truefalse; Indicates whether the component is visible. The default is true.

• 

pixelwidth : posint; The width in pixels of the component.

Description

• 

The Plot command in the Component Constructors package returns an XML function call which represents a Plot Component.

• 

The generated XML may be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document may be inserted into the current document using the InsertContent command.

Examples

withDocumentTools:

withDocumentTools:-Layout:

withDocumentTools:-Components:

Executing the Plot command produces a function call.

PPlotidentity=Plot0

P_XML_EC-Plotid=Plot0,captionalignment=1,captionposition=1,clickdefault=false,clickx=0.,clicky=0.,continuous=false,delay=100,drawcaption=false,enabled=true,endx=0.,endy=0.,pixel-height=400,pixel-width=400,show-border=true,startx=0.,starty=0.,fillcolor=[255,255,255],visible=true

(1)

By using commands from the Layout Constructors package a nested function call can be produced which represents a worksheet.

xmlWorksheetGroupInputTextfieldP:

That XML representation of a worksheet can be inserted directly.

InsertContentxml:

PPlotplotsinx,x=π..π,identity=Plot0,tooltip=My example plot,pixelheight=200:

xmlWorksheetGroupInputTextfieldP:

The previous example's call to the InsertContent command inserted a component with identity "Plot0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "Plot0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

lookupInsertContentxml,output=table

lookuptablePlot0=Plot1

(2)

lookupPlot0

Plot1

(3)

GetPropertylookupPlot0,visible

true

(4)

The next example makes use of action code for a Plot and a Button component.

PPlotplot0,0,color=white,axes=normal,view=0..10,0..10,identity=Plot0,clickdefault,clickaction=update(%Plot0);:

BButtonClear,identity=Button0,action=unassign(':-L'); clear(%Plot0);:

The action code passed with the clickaction option of the Plot component constructor calls a procedure update, and the action code of the Button component calls a procedure clear. These procedures are defined below. The update procedure uses the clickx and clicky values taken on when the mouse pointer is left clicked in the plot.

update := proc(comp)
 global L;
 local cx, cy, v;
 uses DocumentTools, plots, CurveFitting;
 (cx,cy) := Do(comp(clickx)), Do(comp(clicky));
 if type(L,listlist) then
   L := [L[], [cx, cy]];
 else
   L := [[cx, cy]];
 end if;
 Do(comp = display(plot(L, style=point, symbol=solidcircle,
                        symbolsize=15, color=blue, axes=normal),
                   plot(LeastSquares(L, v), v=0..10),
                   view=[0..10, 0..10]));
end proc:

clear := proc(comp)
  DocumentTools:-Do(comp = plot([[0,0]], color=white,
                                axes=normal, view=[0..10,0..10]));
end proc:

Now we insert the components. Following insertion every single left click in the plot augments L with a new data point, and the plot is updated with a point plot and a least squares linear fit of the points in L.

InsertContentWorksheetGroupInputTextfieldB,P:

The Plot component in the previous example is constructed by supplying identity="Plot0" as an option. But the first example on this page had already inserted content with a component with that identity. Hence the identity of the Plot component in the last example is replaced at insertion time. Note that literal instances of "Plot0" and Plot0 are also replaced in all component action code of the inserted content. The consistent replacement allows the action code to function as intended. Such replacement can be confirmed by right-clicking on the inserted Plot and Button components and opening the Edit Click Action... and Component Properties... items.

The fillcolor may be specified to match that of a parent Table Cell.

PPlotidentity=Plot0,plot3dy2sinx,x=π..π,y=2..2,axis=color=DarkBlue,fillcolor=LightGray,showborders=false:xmlWorksheetTablealignment=center,width=380,widthmode=pixels,Column,RowCellTextfieldP,fillcolor=LightGray:

InsertContentxml:

The following example programmatically inserts a PlotComponent with a scaled 3D animation which can be played using SetProperty.

Aplots:-animateplot3d,sinax2y2,x=π..π,y=1..1,grid=200,50,labels=,,,orientation=85,75,0,scaling=constrained,a=1.0..3.0,frames=20:

PPlotidentity=MyAnim,showborders=false,pixelwidth=800,pixelheight=400,InlinePlotA,scale=2.7,width=800,height=400:xmlWorksheetTablealignment=center,widthmode=pixels,width=720,Column,RowCellTextfieldP:

tbInsertContentxml,':-output'=table:

compnmtbMyAnim

compnmMyAnim

(5)

DocumentTools:-SetPropertycompnm,play,true

Compatibility

• 

The DocumentTools:-Components:-Plot command was introduced in Maple 2015.

• 

For more information on Maple 2015 changes, see Updates in Maple 2015.

• 

The DocumentTools:-Components:-Plot command was updated in Maple 2016.

• 

The fillcolor option was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

Component Code

Component Constructors

DocumentTools

Embedded Components

Layout Constructors

XMLTools