PublishPlot Icon

  PublishPlot

Creating high-quality plots for publications

Sorting Data in a Plot

Description

You can enter data into PublishPlot in any order, but if you connect random data points with a line, the line might zig-zag all over the plot area. This script sorts data in any plot to non-decreasing sequence along the X axis.

Script Downloads

Script Name Installation Steps Date
Sort Plot
  1. Click on script name to open source code in a new tab or window
  2. Choose "Save Page As..." (or equivalent) menu command
  3. Save as "Sort Plot.applescript" in the folder you linked to the "Scripts" menu in PublishPlot.
4 Apr 2021

Using the "Sort Plot" Script

To sort any plot, select it and choose "Sort plot" from the "Scripts" menu (if don't select a plot, the front-most one is used). The current data in that plot will be replaced by the same data, but now sorted along the X axis. Note that the sort data will lose error bars created in "#PPXError" and #"PPYError" columns.

This script can be used on built-in bar charts as well and will sort the X labels alphabetically. Note the the order labels appear in a plot document depends on the order the labels are found starting from rear-most to front-most plot. If you sort the labels in the rear-most plot, the labels will rearrange in the plot. But, if you sort data in another plot, the labels may or may not reorder depending on the order the labels appear in other plots. You can sort all plots in a document to guarantee an alphabetical order for the labels.