×
Enter your data in the "data" columns in the spreadsheet, label your axes using the entry fields
(below the spreadsheet), and you will get a graph. Fit a line to your data by selecting a model from the
choices in the middle of the page. Press the "Graph to Clipboard" button to copy your graph, and
then paste it wherever you like.
Entering and Copying Data
Manual Entry - Data can be entered by simply typing values into the data columns in the front panel
spreadsheet. Numbers typed in the "±x" and "±y" columns will drawn as
uncertainty bars on each data point. They are optional, and are not used in the fitting process (weighted fits
are not for beginners). You can navigate between cells using the arrow and enter keys. If you double click in a
cell, you enter "edit mode" for that cell. In edit mode the left and right arrow keys move the cursor
within a cell instead of between cells. The enter key and the up and down arrow keys take you out of edit mode.
If the contents of a cell cannot be interpreted as a number, it will be colored red. If a number is very large
or very small, it will be shown using scientific ("e") notation.
Pasting - Data can also be entered by copying a block of cells from a spreadsheet and pasting it
in (via the ctrl-v paste command). nPlot will correctly parse a paste of one, two, or even four columns at
once. Copying and pasting tab-delimitted data from a Word or Google document also works.
Bad Data - A suspect data point in an
otherwise good data set can be ignored by checking its "skip" checkbox.
Swapping Columns - If you discover that you have accidentally typed your y data into the x
column, just click the "Swap x & y" button. If you have any entries in the
uncertainty columns, they will be swapped too. Holding down the control key while you press the swap button
causes the axis labels to also be swapped.
Using Formulas - The indvidual cells understand math. If you enter 2+2, or 2*2, or 2**2, or 2^2,
or 24/6, or 6-2, or 16^.5 the cell contents will be displayed as the number 4. The value is computed
using the standard conventions for the order of operations. Placing the cursor in a cell recovers the
original math, which allows for editing. (Double-click to enable the arrow keys inside the cell.) This can
be very helpful in linearizing your data. For example, if you have measured something as a function of
velocity and find that the best fit is a square law, you can then just add ^2 (or **2) at the end of
each velocity entry to square it and plot your data as a straight line.
Clearing Your Data - Clicking the Clear Data button will clear the contents of the currently displayed
spreadsheet. Holding down the control key while clicking it will clear all the sheets at once, as well as
all the axis labeling and annotation. If you have selected a portion of your data, hitting the delete key
will clear just that selected portion.
Copying Your Data - nPlot makes a terrible lab notebook. If you typed your data into nPlot first, but now
want it somewhere else, you can highlight the cells you want to copy (click-and-drag, just as you would in a
spreadsheet), and use ctrl-c to copy the data to the clipboard. The highlighting disappears as confirmation
that it has been copied. From the clipboard, you can paste the data somewhere more permanent.
Labeling and Scaling the Axes
Labeling - To label the axes, just type your labels into the appropriate text inputs. There are
separate inputs for the axis units (parentheses are automatically added). There is also a text input for an
optional graph title. If you need superscripts, subscripts, or any special symbols (like Greek letters),
see that section of the manual.
Scaling - It is (mostly) not possible to control the scaling of the graph axes. The auto-scaling
routine is quite robust, and makes reasonable choices. If the data consists of very large or very small
numbers, the axis labels will automatically be drawn using scientific notation. If you feel the need to
have your students set the axis limits by hand, please see the secton on
Multiple Data Sets.
The Origin - By default, the point (0,0) is always included in the axes. This is done for pedagogical
reasons, but you may have a data set where that is really inconvenient. You can turn off this default
behavior in the Preferences menu, but only for the current nPlot session. Next time you launch the program,
the default behavior will be restored.
Select a Model - Choose a model to match your data by clicking on the list of models between the data
sheet and the graph. The process that nPlot uses to draw the line on the graph is known as "fitting"
a curve to the data, and the curve that results is called "the fit" for that model. The
"results of the fit" are the set of constants that do the best job of making
the curve pass as close as possible to all the points in the data set, which is why what nPlot draws is
known as "the best fit." Be aware that every fit from nPlot is technically a "best" fit.
Your job is to choose the correct model.
Deciding Which Model - An objective measure of how well the fit agrees with the data is provided by
the value of the RMSE, which stands for "root mean square error." It is essentially an average of
the amount by which the curve misses each data point. The general rule (also a dangerous rule) is to choose
the model that gives the smallest RMSE. Be aware that a quadratic fit will
almost always give the smallest RMSE, but is almost never the correct model for the data. See the section on
Advanced and Expert Models if you want to use those. If you feel
that your students should look at R2 instead of RMSE, please see the
Philosophy section.
The spreadsheet is actually five separate sheets, selected by the row of tabs (Sheet 1, Sheet 2, etc.) at the top
of the data entry grid. Each sheet supports a completely separate fitting model and has its own plotting symbol
and style of fitting line. They share a single set of axis labels, and the axes will be scaled to accomodate all
curves at once. This feature does not allow you to mix and match completely different data sets. For example,
you cannot put position vs. time and velocity vs. time together in the same graph.
The Preferences button brings up a menu that you can use to make some changes to the appearance of your graph.
These settings (except for the Require (0,0) setting) are saved in your browser cache. They will remain the way
you set them until your cache is cleared.
Grid - By default, your graph includes a faint grid based on the major axis divisions. It you don't want
that, uncheck the Grid radio button.
Show Data - If, for some reason, you want to show the results of your fit without showing all those messy
data points, you can uncheck the Show Data radio button.
Scale With Error Bars - If you have error bars on your data points, the graph will be scaled so those bars
are fully shown. If you de-select this option, then the scaling will be calculated using only your data points,
and the error bars may be clipped.
Download - If you want to download your graph as a graphics file, check this radio button. If you want your
fit results as separate text file, check the "Also text" radio button. You will need to allow
multiple downloads when you get the pop-up asking.
Require (0,0) - By default, nPlot always includes the orign in your graph. If you have data that covers a
limited range very far from the origin, you may want to override this default by unchecking the radio button.
This setting is not saved. It will be reset to default the next time you launch nPlot.
Professional Mode - If you check this, nPlot will use the uncertainty in each fit result to determine the
correct number of significant figures for each fitting parameter. The "correct" number of significant
figures is possibly a matter of opinion, of course. What nPlot does is round the uncertainty to two significant
figures and then round the fitting parameter to the same number of decimal places.
Auto Zoom - nPlot will try to adjust itself to fill your computer screen. Because web browsers operate in
a kind of "sandbox" to protect your computer from malicious web sites and blah, blah, this may not work
well on your device. If this feaure is giving you trouble, turn it off.
Symbols, Colors, and Lines - Pressing each of the five radio buttons in turn will show you the default symbol,
line color, and line type for each of the five data sheets. Below the radio buttons is a set of dropdown menus
that will allow you to make different choices for each sheet. Go wild.
The Tangent Finder does just what it says. When activated, it gives the slope of the fit at the x-value of
the mouse position. By default, when the Finder is activated, the Lock To Data option is on, which
restricts tangent finding to the x-values of the input data points. The x value and slope at that x value
appear just below the tangent finder controls. The finder operates on whichever of the five sheets has been
selected. If you want to include a tangent in your downloaded graph, slide the mouse off the top or bottom
edge of the graph at the desired x-value.
This feature is designed to let you paste the results of a fit right on the graph instead of having to copy the
numbers down separately. Clicking the Annotation button brings up the annotation menu, which has buttons for
adding a fit result, a note or an arrow. There is also an Edit button which will let you change any of the
annotations you have already placed.
Adding a Fit - If you have fit for only a single data set, then pressing this will automatically drop the
results on your graph as a block of text. Use your mouse/trackpad to position the block, then click to leave it
there. If you have multiple fits on multiple sheets, then you will get a popup menu. As you hover the cursor
over each sheet name in the list, the datapoint for the associated curve will turn red on the graph. Click on
the sheet whose fit results you want to place next. If you type something in the Note box, when you hit the Add
Fit button, that text will be added to the start of the next fit result you place. If you change the model used
on a data set, the fit annotation for the old model will automatically be erased.
Adding a Note - To add a note to the graph, type the text in the Note box first, then press the Add Note
button. As with the fits, click to leave the note where you have positioned it. Notes can include
subscripts, superscripts, and Greek letters.
Adding an Arrow - If you have multiple fits and multiple annotations, it can be useful to indicate which
results go with which curves. That is where arrows come in. Arrows are drawn tip-to-tail. Click the add arrow
button, then click in the graph where you want the arrow to start and click again where you want it to end.
Editing Annotations - This button will bring up a list of all the annotations that have been added to your
graph. The list tells you only whether a particular annotation is a fit, note, or arrow, but it doesn't tell
you which fit, note, or arrow. But as you hover the cursor over each item in the list, the corresponding
annotation will highlight red in the graph. Click on the fit you want and you can reposition the block of text.
If you click on a note, the note text will first be loaded into the Note box so you can edit it. Click on Add
Note to position the edited text. If you click on an arrow, you first get to reposition the tail, and then the
tip. Clicking on the "×" next to
an item will delete it. If you have multiple data sets and erase one data set (using the Clear Data button)
then the annotation associated with that data set will remain on the graph. You will have to delete them by
hand using this editing function.
Adding Max/Min Slope Lines - If you have a linear fit on any sheet, you can use the annotation
menu to manually add additional lines to the graph. This feature is intended for students who need to draw
IB style graphs. The completed line is drawn using dashes, and the slope and intercept are reported in the
annotation dialog. If desired, this information can be manually added to the graph using the Add Note feature.
You can draw as many lines as you like, and although you cannot change a line after it has been drawn, you can
remove it using the Edit feature.
Saving & Recalling Your Graphs
Saving - Your entire graph can be saved for later recall by clicking the Save Graph button. Type a
name in the text input first, or nPlot will complain. If the name matches an existing saved graph, that
earlier graph will be overwritten. There is no "are you sure?" warning! The graph is saved on
your computer only. It cannot be accessed from any other device.
Recalling - If you click the Recall Graph button you will be shown a list of all the graphs saved in
your browser. Click on a name in that list and the graph and data will be restored exactly as they were
when you saved them. If nPlot detects that there is already data in the spreadsheet, it will ask before
erasing your current graph and replacing it with the recalled one.
Deleting - If you hold down the shift key while clicking on a saved graph name, that graph will be
deleted instead of recalled. You will not be asked if you are sure.
Impermanence - Your graphs are stored in the browser cache. If the cache is cleared for any reason
you will lose all your saved graphs. Think of this graph saving feature as a convenience and not an
archival record. Keep a copy of your data in e.g., a Google Sheet.
Pasting or Printing Your Graph
There are actually three separate ways to get a useful copy of your graph. Which one you should choose
depends on what you want to do with the graph.
Copy to Clipboard - This is the default option. Clicking the Graph to Clipboard button puts a copy of the
graph in the system clipboard. From there it can be pasted into a document and printed. You can also paste it
into the spreadsheet you are using as a lab notebook.
Open in a Tab - This option is designed for making a quick hard copy that you can tape into a real (made
from paper!) lab notebook. Hold down the control key and the "Graph to Clipboard" button changes to
the "Graph in New Tab" button. Click this button and your graph will appear by itself in a new tab.
Print that tab to get a graph suitable for taping into a notebook.
Download an Image - If you check the "Yes, download" radio button in the Preferences menu, then
the "Graph to Clipboard" button changes to the "Download Graph" button. Clicking it will
download your graph as a graphics file (named using your axis labels as
"y-axis_label_vs_x-axis_label.png") that you can use however you like. If you also select the
"Include fit" radio button, you will get a second (plain text) file containing the results of all your
fits. If you request the text file, allow multiple downloads when the pop-up asks your permission.
Superscripts, Subscripts, and Symbols
Superscripts - To get a superscript in any text input (axis labels, units, plot title, or annotation
notes), just precede the numerical superscript with the caret symbol "^". For example, to get
v2, type v^2. Superscripts are restricted to numbers only. All digits between the caret and
the first non-digit character are assumed to be part of the same superscript.
Subscripts - Unlike superscripts, subscripts can contain (almost) anything you want: plain text, Greek
letters, and numerical superscripts. However, you have to tell nPlot when the subscript starts and when the
subscript ends. Subscripts start with "_{" and end with "}". For example,
typing F_{net} gives Fnet. There are some restrictions. Subscripts may not have
subscripts, and if your desire is to have curly brackets as part of your subscript text, that is guaranteed
not to work right.
Greek and Other Symbols - To get a Greek letter, type a backslash "\" followed by the
name of the Greek letter. For example, type e.g. \Delta, \delta, or \mu to get Δ,
δ, or μ. If an uppercase Greek letter is the same as a character in the Roman alphabet, no
translation is made. Disappointingly, typing \Alpha just gives \Alpha, not the A you were hoping
for. To make it easier to read what you are typing, the first blank space between the Greek letter and the
rest of the text is ignored. If actually want a space after the Greek letter, type two spaces in your
input. For example, both "\DeltaL" and "\Delta L" will print as ΔL, but
"\Delta L" will print as Δ L.
Special Characters - The Greek symbol processor also understands a few special characters (which means
the same business about spaces applies). These characters are \deg (°), \times (×),
\sqrt (√ ), \pm (±), and \el (ℓ).
Advanced and Expert Models
The Basic models are all "linear," while the Advanced and Expert models are "nonlinear."
Linear and nonlinear in this context have specific mathematical meanings. If you want to know more about these
meanings, you should read chapter 15 of Numerical Recipes by Press, Teukolsky, et al. To use
nPlot, however, all you need to know is that a fit to a linear model (all the ones on the Basic tab) cannot
fail. No matter how unrelated the shape of the model and the shape of your data, you will get some kind of an
answer. Nonlinear models, on the other hand, require you to guess what the answer is first. If your guesses
are close enough, then the algorithm will quickly converge to a best fit set of parameters. If they are not,
then the algorithm will wander off in parameter space and never be heard from again. If it seems unfair that
you can only get the answer if you already know the answer, you are right. Life is like that sometimes. The
good news is that, since guessing can be hard, nPlot will guess for you.
Advanced Models - For these two models, the guessing algorithm works really well, as long as the majority
of your data has positive values for both x and y. If you
follow that simple rule, then these models will appear to you just like the basic ones: select the model and
instantly get a fit.
Expert Models - For these models, nPlot is still going to guess for you, but for reasons, it might not do
such a great job. So, when you select an expert model, nPlot will make the guesses, show you the curve that
results, and let you change the guesses before the nonlinear fit starts. Probably the best strategy is to just
accept nPlot's guesses by hitting the Go button, and only try guessing yourself if the fit fails. I said nPlot
might not make great guesses, but maybe I was being modest.
Failure is an option - If there really is no reasonable relationship between your data and the model you
have chosen, then the Levenberg-Marquardt fitting engine will not converge and you will get a message that the
fit has failed. A less likely, but still possible, outcome is that the fit converges, but to parameter values
that make no sense. If you are really sure that you have the right model, then you can try again and adjust the
intital guesses by hand before hitting Go. All that being said, the most likely reason for a failed fit is that
the model is wrong or the data are complete nonsense.
As every teacher knows, designing a course requires making choices: what to include and what to leave out. There
are many teachers who believe that students can learn a lot through making graphs by hand: how to linearize
data, how to choose an appropriate scale for the axes, how to decide on what is or is not a reasonable line
through the data. As it happens, I am one of those teachers. But learning these skills takes time, and it can
actually be quite a while before students have mastered them well enough to see through the graphing mechanics
to the physics you want to teach them. If you have that time, then you should teach your students to graph
their data by hand. nPlot was created because I did not have that time, and because, while there were many
computer graphing tools to choose from, they all still wasted time that I could use better teaching physics.
Also, since wherever they go in life, our students will likely have access to computer based graphing tools
(from an icon right next to the one for Chat GPT), they might as well know what a good one looks like.
Scaling - Left to their own devices, students will naturally make boneheaded choices when scaling
their graphs. Many computer-based graphing programs will make boneheaded choices of their own. In designing
nPlot, I made a decision to take scaling completely out of the students' hands. The data will always be more or
less centered and fit completely within the graph. The number and placement of axis divisions will be wisely
chosen. There will be no more squinting at a row of dots pressed against the x or
y axis in an attempt to figure out if they make a straight line or a curve. There will
be no tick marks placed at locations that can only be represented using an infinite number of decimal digits.
What about comparisons? - If you are used to making your students all use the same scale so they can
compare what is the same and what is different, try using the multiple sheets feature of nPlot. Have two or
three lab groups share their data so that all the data sets appear together on the same graph with the same
scale. Making comparisons doesn't get more direct than that.
RMSE vs. R2 - These two quantities are used to answer two completely different questions.
R2 (the square of the linear correlation coefficient) will provide an answer to a question like
"Does my crop yield depend on the amount of fertilizer I use?" Or, at the next level, "Does crop
yield depend more closely on fertilizer per acre or irrigation per acre?" These are not physics questions.
In an introductory physics lab, we are not in doubt as to which is the correct independent variable. Rather, we
want to know which of the many possible mathematical relations between x and
y is the correct one. The RMSE is what answers that question. For more on this topic
than you really want to know, see Data Reduction and Error Analysis for the Physical Sciences by
Bevington and Robinson.