# 2.9.3 Managing Layers

## Creating a panel plot

The newpanel X-Function creates a new graph with an n x m layer arrangement.

### Creating a 6 panel graph

The following example will create a new graph window with 6 layers, arranged as 2 columns and 3 rows. This function can be run independent of what window is active.

newpanel col:=2 row:=3; Remember that when using X-Functions you do not always need to use the variable name when assigning values; however, being explicit with col:= and row:= may make your code more readable. To save yourself some typing, in place of the code above, you can use the following:
newpanel 2 3;

### Creating and plotting into a 6 panel graph

The following example will import some data into a new workbook, create a new graph window with 6 layers, arranged as 2 columns and 3 rows, and loop through each layer (panel), plotting the imported data.

// Create a new workbook
newbook;

// Import a file
path$= system.path.program$ + "Samples\Graphing\";
fname$= path$ + "waterfall2.dat";
impasc;

// Save the workbook name as newpanel will change %H

## Aligning layers

The layalign X-Function is used to align one or more layers relative to a source/reference layer.

The following example will bottom align layer 2 with layer 1 in the active graph window.

layalign igl:=1 destlayer:=2 direction:=bottom;

The following example will left align layers 2, 3 and 4 with layer 1 in the active graph window.

layalign igl:=1 destlayer:=2:4 direction:=left;

The following example will left align all layers in Graph3 with respect to layer 1. The 2:0 notation means for all layers, starting with layer 2 and ending with the last layer in the graph.

layalign igp:=graph3 igl:=1 destlayer:=2:0 direction:=left;

laylink igl:=1 destlayers:=2:0 XAxis:=1;