Format for Tables to Plot in PublishPlot
PublishPlot makes extensive use of plot tables for creating, editing, saving, and exporting plot data. This help topic documents all the rules for a plot table. The following block illustrates the various options for a PublishPlot plot table:
# Sample Table 1 #setLineType dotted dashed solid #setName x x^2 x^3 0 0 0 0 1 1 1 1 2,2,4,8 3 , 3 , 9 , 27 4 4 16 64 # Sample Table 2 #setColor red #setName x 0 20 1 10 2 0 3 10 4 40
The rules for such tables are
- The table begins with any number of lines beginning in "#" or the number sign. These lines are used for commands to control the plot style. Any lines beginning in "#" but not having a valid command are ignored and can therefore be used for comments.
- Following the "#"" lines are any number of data lines.
- Each data line is divided into fields. The fields can be separated by spaces, commas, or tabs. When tabs or commas are used, leading and trailing spaces in the fields are ignored. When spaces are used any number of consecutive spaces is equal to a single space or one delimiter. For example:
- 0 0 0 0 - has four fields all equal to "0" separated by tabs.
- 2,2,4,8 - has four fields "2", "2", "4", and "8" separated by commas.
- 3 , 3 , 9 , 27 - has four fields "3", "3", "9", and "27" separated by commas. Because commas separate the fields, the leading and trailing spaces in the fields are ignored.
- 1 2,,4 - has four fields "1", "2", "", and "4". Some are separated by commas while others are separated by spaces. One field is empty which can only be delimited by commas or tabs.
- The first field in each row is the x data point. For numeric plots, it must be a valid number, a number followed by "%", or a date. Dates will be converted to number (year plus fraction within the year). See below for details on entering dates. For bar charts, all x values must be text labels. See bar chart help for details.
- Each subsequent field provides any number of y data points for that value of x. Each entry can be a number, a number followed by "%", or a date. Any empty fields or fields with invalid data are ignored for that data set. Each column of y will create a separate plot element.
- A blank or empty line indicates the end of a table. A new table can begin after that break. Thus the input text data can include any number of tables.
- You can add error bars to any points by following selected table columns with columns of error bars.
You can create tables using any text-editing software. You can also create tables using a table of cells in spread sheet software. Most spread sheet software will let you drag and drop cells or copy cells. When dragged or pasted to PublishPlot, those cells will appear as tab delimited fields and thus be compatible with above table format. These is a special option for dealing with tables in Mathematica format.
Entering Dates
PublishPlot has a custom "Smart Dates" feature which means you can enter dates almost any way you want and the date you intended will usually be deciphered. A date consists of the following possible date parts:
<DAY>: number of the day in a month<MONTH>: name or number for the month (including Hebrew calendar month names).<YEAR>: year number. Four digit years are safest. Two digit years are assumed to be in the 21st century. To enter an actual two digit year, use leading zeros (e.g., 0032 AD).<AD or BC>: indicates years before or after birth of Christ (AD is assumed if not provided).
The date parts must be separated by delimiters. The allowed delimiters are a space character, a slash (/), a dash (-), a comma (,), or a period (.), but because spaces and commas are also delimiters for table columns, dates that use them as delimiters too must be enclosed in quotes (e.g., "May 25, 2022"). The date parts can usually be in any order. If month is given by number and day of the month is less or equal to 12, your local settings will determine if that means day/month or month/day (i.e., whether 1/10/2023 is October 1 or January 10). Finally, partial dates are allowed, which are dates with just a month and year or just a year.
Plotting Commands in a Table
The comment lines at the start of the table can include commands to set features of the plots in the table. Command lines, like data lines, are divided into fields. The first field (including the "#") is the command name. The remaining fields apply plot options to the corresponding columns in the table. The possible case-insensitive commands are:
- #setName - name of the plot.
- #setColor - line color (see notes).
- #setLineWidth - line width (see notes).
- #setLineType - line type to connect points (none, solid, dotted, dashed, dash-dot, dot-dash, or filled — all case insensitive).
- #setSymbolType - symbol drawn on points (none or any symbol in the symbol type menu when customizing plots).
- #setSymbolSize - symbol size (see notes).
- #setSymbolLineWidth - symbol line width (see notes).
- #setSymbolLineColor - symbol line color (see notes).
- #setSymbolFillColor - symbol fill color (see notes).
- #setPatternType - symbol fill pattern (horizontal, vertical, checkerboard, "slant down", "slant up", or "slant both" corresponding to options in the pattern popup menu or "solid" to not use a pattern).
- #setXTitle - plot x axis label (replaces current label).
- #setYTitle - plot y axis label (replaces current label).
- #setErrorBarType - 1 to plot error bars if available in special columns of data, 2 to calculate and plot mean values and standard deviations, 3 to display data as a box & whisker style plot, 4 to display data as a box & whisker style plot with outliers, 5 to display data as a violin style plot, and 6 to display data as a violin style plot with outliers. Using a negative glue selects the same options (by absolute value of the number), but hides those plot features (i.e., checks the "Hide" box in the Error Bars / Statistics section).
- #setStatsTolerance - width of x data groupings when doing statistics calculations.
- #setErrorSize - size of error bar end caps and half width of boxes in box & whisker plots (see notes).
- #setErrorLineWidth - error bar and box & whisker line width (see notes).
- #setErrorLineColor - error bar and box & whisker line color (see notes).
- #setBoxFillColor - fill color for box & whisker or violin plots (see notes).
Some command rules are
- Any command values with a space (such as a name, a symbol type, or a pattern type) must either be enclosed in quotes to indiciate it is a single field or have the spaces replaced by an underscore character (e.g., left_triangle). The space option can avoid Excel's nasty habit of removing quotes in cells without asking.
- Colors can be set by name (black, blue, brown, clear (i.e., transparent), cyan, darkGray, darkGreen, gray, green, lightGray, magenta, maroon, orange, purple, red, white, yellow - all case insensitive) or by RGBA values entered as "(r g b a)" where r, g, b, and a are the red, green, blue, and alpha values entered as floating point numbers between 0.0 and 1.0 and separated by spaces or underscores. The RGBA values can be bracketed by (), {}, or [] or provided without brackets. When spaces are used, the color name must be enclosed in quotes (e.g.,"(r g b a)").
- Line widths or symbol sizes are always entered as a percentage of the plot diagonal (a common approach for graphic artists). An value of 0.14% corresponds to a 1 pixel line on a full-page, landscape-mode plot (i.e., a plot with a 10 inch diagonal). Good design usually has lines thicker than 0.14% and symbol sizes larger than 1%.
Mathematica Tables
Mathematica (by Wolfram Research) can easily create tables of data and PublishPlot can directly plot them. For example, the following Mathematica command provides a general way to create a table to plot any function supported by Mathematica:
Table[{x, N[x Cos[x]]}, {x, 0, 10, 1}]
{{0, 0.}, {1, 0.540302}, {2, -0.832294}, {3, -2.96998},
{4, -2.61457}, {5, 1.41831}, {6, 5.76102}, {7, 5.27732},
{8, -1.164}, {9, -8.20017}, {10, -8.39072}}
You can copy the table output and paste it into any PublishPlot document to plot the data pairs in the table (Mathematica does not support text drag and drop). Alternatively, you can export the table to a file and import or drag the resulting file into PublishPlot. You can write any table created in Mathematica to a plain-text file by using:
Export["/Users/myaccount/file.txt", aTable]
To plot more than one data set at the same time, add more entries to the Mathematica command to add more columns to the table, such as:
Table[{x, N[x Cos[x]],N[Sin[x]]}, {x, 0, 10, 1}]