Dept. Logo

Main   |   PHY 121   |   PHY 122

Manual Interface

Plot title:

x-axis label:
y-axis label:

(Note: ranges are not required. Leave these boxes blank for automatic range selection. Adjust if necessary.)
x-axis range: Min: Max:
y-axis range: Min: Max:
Legend location:   

Use x-error bars?   
Use y-error bars?   

Perform linear fit?  
If so, fit through origin?  

x1:   +/-     y1:   +/-
x2:   +/-     y2:   +/-
x3:   +/-     y3:   +/-
x4:   +/-     y4:   +/-
x5:   +/-     y5:   +/-
x6:   +/-     y6:   +/-
x7:   +/-     y7:   +/-
x8:   +/-     y8:   +/-
x9:   +/-     y9:   +/-
x10: +/-     y10: +/-
x11: +/-     y11: +/-
x12: +/-     y12: +/-
x13: +/-     y13: +/-
x14: +/-     y14: +/-
x15: +/-     y15: +/-
x16: +/-     y16: +/-
x17: +/-     y17: +/-
x18: +/-     y18: +/-
x19: +/-     y19: +/-
x20: +/-     y20: +/-

                    

Use the following buttons to automatically give all x or y data the same error:
X error:
Y error:

Back to Top
Google Sheets Interface
To use this section, you need to enter your data into a copy of the Google Sheet for Plotting Tool Data. You then need to click "File>Download as>Comma-separated values (.csv, current sheet)" to download the file in a form that is processed by this program. Then, you upload that file here, and click the button to make your plot.

Upload your .csv file here:

Back to Top
Plotting Tool FAQ

Debugging

Hopefully, the warnings and error messages you receive will help your resolve any technical issues you have. If you are unable to solve your issues on your own, come to the help room.

Report any bugs to phy_introlabs@stonybrook.edu (but please make your own attempts, with TAs in the help room, to resolve said bugs first). Please include a screenshot of inputs (if using the manual interface) or the CSV file used (if using the CSV file interface).

Do not take a lack of warnings to indicate a perfect plot. Other errors (especially misplaced decimal points) can still cause problems, and you are responsible for making sure these do not occur.

You should check your data and make sure it follows the trendline (if you expect it to), and check that your error bars are reasonably sized (in particular, not larger than the range of your data!).

Note that slopes and intercepts with very large or small magnitude will display in scientific notation. Make sure to notive when this happens, so that your answers are not wring by orders of magnitude!

Advanced Techniques for Plotting Tool Use

Here are a few more technical features that can either make your life easier or can make your plot look nicer:

  • If you do not include x/y min/max, the plotting tool will choose defaults based on the range of your data (10% of the range of your data above/below the top/bottom of your data).
  • To input in scientific notation, format your numbers as "1.2e-6" (this is valid for any numerical input).
  • To input mathematical expressions (such as \(x^2\)) in your title or axis labels, first write your expression in \(\LaTeX\), then enclose it between dollar signs. E.g.: "$\sqrt{\frac{L}{g}}$" will output as \(\sqrt{\frac{L}{g}}\); "$ax^2+bx+c$" will output as \(ax^2+bx+c\).
    • An equation editor (which will give you the \(\LaTeX\) code for a mathematical expression) is available here.
    • This is one way to have Greek letters in your axis labels, but you can also just copy-paste the character from elsewhere into the relevant text box.
  • To have a multi-line title (or axis label), type a "\n" where you want the line break.
Back to Top
How It Works

Your inputs here are first forwarded to a PHP script. This PHP script compiles your data (extracting it from the CSV file if you choose to use that interface) and runs basic validation on it (giving warnings or errors if something is wrong, and doing its best to fix such issues in a minimally-intrusive way).

This script then saves your actual data to a file, and calls a Python script (from the command line) with your other plot parameters. This python script reads your data back from that file, runs the fitting algorithm, and makes the plot. It then saves the plot as an image which is read by the (HTML surrounding the) PHP script.

The python script makes the plot using the Matplotlib library. If you want to make a plot with a similar style, you can read the documentation provided there.

The optimization is a standard vertical least-squares linear fit, either with or without intercept. This matches what most simple programs (such as Excel or Google Sheets' LINEST routine) will do if asked to estimate the best fit line.

More advanced methods are possible, but are difficult to execute due to needing to optimize more complicated functions of the data. Standard vertical least-squares fitting is analytically solvable with linear algebra; a more detailed orthogonal distance regression requires a numerical optimization routine.

As a result of this data-fitting procedure, your error bars are not actually used in performing the fit, nor estimating its uncertainty. Instead, the uncertainty is estimated based on the size of the scatter in your data.

Back to Top