Satimage Previous | Next
Customize the data presentation
Home Documentation Smile Smile Tutorial Write a data visualization script Customize the data presentation  

Here we shall start with the first example in the previous page, where we plotted the second vs the first column in an ASCII file, and we shall customize our graph.

Each class of object supports its own set of properties. What properties does a curve support?
Write the word curve in any AppleScript terminal. Select the word, then press ⌘⇧F: this will show the dictionary's entry for curve, where you can find the properties that we use below.
The view v which contains the curve is an object of the class plot view. The plot view class is a child of the chart view class, thus v owns the properties shown in both entries plot views and chart views. The window w belongs to the graphic window class.

set f to (navchoose file without multiple files) as alias -- you are asked to select a file
set {x, y} to extractcolumn {1, 2} in f skipping 1 as array of real -- returns a list of two arrays of real
set w to make new graphic window
set v to make new plot view at w
set c to make new curve at v with properties {xdata:x, ydata:y}

set pattern style of c to 8 -- one bullet for each data
set pen width of c to 2 -- make the stroke thicker
set theName to name of (info for f) -- the file's name
set name of c to theName -- show the file's name as the legend for c
set legend kind of v to 2 -- show the legends in a cartouche rather than on the curves
set xlabel of v to "x axis label here" -- label for the x axis
set ylabel of v to "y axis label here" -- label for the y axis
set label text font of v to "Helvetica"
set label text size of v to 14
set name of v to "A customized plot view" -- the view's name prints above its frame
set margins of w to {0, 0} -- no scrolling required
set message bar of w to "Click the curve to display a point's coordinates."
draw w-- update the display


Import script
Now you may want to add to the script in order to change more properties, for instance the curve's color (its pen color property).
Copyright ©2008 Paris, Satimage