-- optionKey:c -- Script for PublishPlot -- Combines all curves in current plot into a single -- curve and then plots it with calculations -- of standard deviations over 10 blocks of x values -- User can change stats tolerance later if desired or switch to box & whisker elements -- Written by John A. Nairn, 12/1/2020 tell application "PublishPlot" -- needs a document to proceed activate if number of documents is 0 then display dialog "No open documents" return end if tell front document -- needs at least two plots to combine set numCurves to number of every plot if numCurves < 2 then display dialog "Open a document with multiple curves and try again" return end if if bar chart is true then display dialog "Combining of curves does not work for bar chart documents" return end if -- create table with each curve's data -- track range of x values set slist to {} set sdata to a reference to slist set xmin to 1 set xmax to 0 repeat with i from 1 to numCurves set xy to plot data of plot i set xdata to item 1 of xy set ydata to item 2 of xy set x to (a reference to xdata) set y to (a reference to ydata) repeat with j from 1 to number of items in x set xval to item j of x set yval to item j of y set end of sdata to xval & " " & yval & return if xmax < xmin then set xmin to xval set xmax to xval else if xval > xmax then set xmax to xval else if xval < xmin then set xmin to xval end if end repeat end repeat -- preamble to plot table set pdata to {} set end of pdata to "#setLineType dotted" & return set end of pdata to "#setColor red" & return set end of pdata to "#setSymbolType circle" & return set end of pdata to "#setSymbolLineColor red" & return set end of pdata to "#setErrorBarType 2" & return set end of pdata to "#setErrorLineColor red" & return set end of pdata to "#setStatsTolerance " & ((xmax - xmin) / 10.0) & return set end of pdata to "#setName \"Combined curves\"" & return -- add to plot plot table data (pdata as string) & (sdata as string) end tell end tell