Skip to content
geneticslab

How to make a scatterplot and obtain trendline

Scatterplot Generator

This page outlines how to create a scatter plot. It provides JavaSript app to produce a scatter plot between a single X (independent) variable and up to five Y (dependent) variables. If two or more Y variables are provided, the option to produce a second Y axis is also provided.

To review about scatter plots, see Chapter 4.5 in Mike’s Biostatistics Book. For more on use — and limitations — of adding second Y-axis, see Chapter 4.6 in Mike’s Biostatistics Book.

Features

Data import and variable selection

  • Import data from a CSV file or paste data directly from a spreadsheet.
  • Select one independent, X, variable and up to five dependent Y variables.
  • Display multiple datasets on a single graph.
  • Optionally assign a second Y variable to an independent vertical axis.
  • Automatically omit missing or nonnumeric X–Y pairs from individual series.

Graph customization

  • Customize graph titles and axis labels.
  • Adjust title, axis-label, tick-label, and legend font sizes.
  • Independently select point colors, sizes, and symbols for each Y variable.
  • Optionally connect observations in increasing X order or original data order.
  • Customize connecting lines and regression curves using solid, dashed, dotted, or dash-dot line styles.
  • Adjust line thickness independently for each data series.

Regression and curve fitting

Independently fit any of eleven regression models to each Y variable:

Model Equation Typical application
Linear y=a+bx Relationships characterized by a constant rate of change
Linear through the origin y=bx Direct proportionality, calibration curves, and relationships with a theoretically justified zero intercept
Quadratic y=a+bx+cx^2 Curvilinear relationships, physiological optima, and responses with a single turning point
Cubic y=a+bx+cx^2+dx^3 Complex curvilinear relationships with multiple changes in direction
Exponential y=ae^{bx} Unrestricted population growth, radioactive decay, and first-order degradation
Logarithmic y=a+b\ln(x) Diminishing responses and relationships characterized by progressively smaller changes
Power y=ax^b Allometry, metabolic scaling, and relationships between body size and physiological traits
Three-parameter y=\frac{K}{1+e^{-r(x-x_0)}} Population growth, microbial growth, and sigmoidal responses with a zero lower asymptote
Four-parameter logistic (4PL) y=A+\frac{K-A}{1+e^{-r(x-x_0)}} Dose–response relationships and sigmoidal growth with a nonzero baseline
Generalized logistic (Richards’ curve) y=A+\frac{K-A}{[1+\nu e^{-r(x-x_0)}]^{1/\nu}} Asymmetric sigmoidal growth, organismal development, and microbial growth kinetics
Michaelis–Menten / Monod y=\frac{V_{\max}x}{K_m+x} Enzyme kinetics, nutrient uptake, and substrate-limited microbial growth

These models support the investigation of linear and curvilinear relationships, biological scaling, population growth, dose–response relationships, enzyme kinetics, and nutrient-limited microbial growth.

Regression statistics and model evaluation

  • Display fitted regression equations and estimated coefficients.
  • Report sample size, coefficient of determination (R^{2}), adjusted R^{2}, residual sum of squares (RSS), and root mean square error (RMSE), as appropriate for the selected model.
  • Report applicable inferential statistics for linear regression, including slope standard errors, p-values, and 95% confidence intervals.
  • Distinguish centered and uncentered R^{2} for regression models with and without an estimated intercept.
  • Identify the fitting scale used for transformed regression models.
  • Report nonlinear optimizer convergence and relevant model limitations.
  • Compare alternative regression models to assess their suitability for describing observed biological relationships.

Graph and results export

  • Export customized graphs as PNG images.
  • Export graphs and accompanying regression statistics as PDF documents using the browser’s print-to-PDF capability.

Learning and exploration

  • An included simulated yeast growth dataset allows users to explore graph customization, compare growth curves between media treatments, and investigate how different regression models describe biological processes.

All calculations and graph generation take place within the user’s web browser. No statistical software installation or data upload to an external server is required.

Authorship: created by Mike Dohm with ChatGPT, OpenAI’s GPT-6.2, as primary coder.

For bar plots, see How to make a bar chart.

 

Tips for scatter plots in spreadsheet apps

Here’s a short video stepping you through creating a trend line from a scatterplot in Google Sheets. The video also shows how to log-10-transform the X variable.

Steps to make the plot and obtain trend line

Example data were reported How to obtain slope of the regression1

  1. Take the time to arrange your data columns so that X (eg, MYA or logMYA) and Y (e.g., genetic Distance) columns next to each other, the column with X variable left of the column with Y variable.
  2. Highlight the X and Y columns (click and hold on the header for the X column then move to the Y column)
  3. From menu bar select Insert → Chart
  4. Select data series by clicking on any data point in the chart
  5. Check Trendline from the Chart Edit menu at right of your screen
  6. Label, select Use equation
  7. Check Show R^{2}.

Next, log10-transform the X variable (eg, logMYA)

  1. Create a new column, label logMYA. For this example, let’s go with column G. I assume, again for this example, that the raw MYA are in column C and the Distance values are in column D.
  2. In the first open cell, G2, type the equals sign and the function call =log10(c2), then hit enter. The cell will be updated with the log-base-10 of the value in C2.
  3. Complete the transform for the rest of the values. An easy way to do this is to double-click on the “+” that appears when you hover the mouse over the lower-right part of the cell.
  4. Now, copy and paste all values from column D to column H.
  5. Make the new plot and obtain slope and R^{2} from the new trendline by repeating steps 3 – 8.