Curve fitting

Area under the curve (AUC)

Integrating a measured signal over an interval turns a full trace into one summary exposure, dose, charge, or band-intensity number. Even a numerically exact integral becomes misleading if the baseline convention, boundary interpolation, sub-baseline dip rule, or sampling density around sharp peaks does not match the scientific question.

Updated · 7 min read

On this page
  1. What the trapezoidal rule actually computes
  2. Choosing a baseline: Zero, Constant, or Endpoint Line
  3. Positive-only (iAUC) vs signed net integration
  4. Sampling bias, curvature, and common AUC traps
  5. Comparing Autoplot, GraphPad Prism, OriginPro, and SciPy
  6. AUC - Area Under Curve in Autoplot
  7. Frequently asked questions

What the trapezoidal rule actually computes

For ordered finite coordinate pairs (x0,y0),(x1,y1),…,(xn−1,yn−1) inside an integration window [xmin,xmax] with x0≤x1≤…≤xn−1 and reference baseline b(xi), discrete composite trapezoidal integration approximates the continuum integral ∫xminxmaxyeff(x)dx as a sum of straight chord trapezoids between consecutive samples:

AUC=∑i=0n−2yeff,i+yeff,i+12(xi+1−xi)

Each step weights the average effective height by the local spacing Δxi=xi+1−xi, so the method works directly on uneven time points (such as sparse clinical blood draws or variable dwell times) without resampling onto a uniform grid first. As Matthews et al. (1990) emphasize for serial biomedical measurements, this simplicity lets AUC summarize overall response without forcing a parametric pharmacokinetic model onto noisy individual subjects.

In Autoplot (buildAUCResult), raw (X, Y) pairs are first zip-paired, filtered to finite values, sorted in ascending x order, and evaluated strictly in the data's natural linear x units rather than transforming coordinates into log10x. When xmin or xmax falls between two adjacent measured coordinates (xk,yk) and (xk+1,yk+1), Autoplot linearly interpolates the boundary value inside [xfirst,xlast]:

y(x∗)=yk+x∗−xkxk+1−xk(yk+1−yk)

No extrapolation is performed outside the measured data range, and nearly coincident points within 10−12 in x are deduplicated before summation so vertical step artifacts do not double-count boundaries.

Choosing a baseline: Zero, Constant, or Endpoint Line

Before looking at any numerical area, inspect what counts as zero response on the y-axis. Three baseline models cover most laboratory and clinical traces:

Baseline modeReference formula b(x)When to use itWatch out for
Zerob(x)=0Absolute zero is physically exact (zeroed detector counts, calibrated concentration above zero)Adds pre-stimulus offset b0(xmax−xmin) directly into total area
Constantb(x)=b0Trace sits on a steady dark level, blank reading, or fasting baseline b0Must supply an explicit numeric Value; wrong b0 scales linearly with window width
Endpoint Lineb(x)=y0+x−x0x1−x0(y1−y0)Linearly drifting background (thermal drift, HPLC gradient ramp, bleaching slope) anchored at [xmin,xmax]Anchors directly on interpolated y(xmin) and y(xmax); noisy edge points tilt the chord

If a noisy tail fluctuates at xmin or xmax, inspect whether shifting the window slightly alters Endpoint Line, or switch to full multi-component modeling via multi-peak fitting and peak deconvolution when neighboring peaks overlap the baseline flanks. For broader model choice decisions before committing to an integration rule, see how to fit a curve to data.

Autoplot X&Y Plot showing Concentration (mg/L) against Time (h) from 0 to 16 h, with blue Plasma response curve, Fine Dotted orange vertical bounds at xmin=1 and xmax=12, shaded blue AUC fill resting at Constant baseline 1.2 while leaving the post-10.7 h sub-baseline undershoot unshaded, and Figure Inspector Results reporting area=34.0482, range=1..12, points used=45, and peak in range x=2, y=9.13966
Oral-dose response integrated over [1, 12] h with a Constant baseline of 1.2 mg/L: Fine Dotted vertical bounds frame the window, clamping keeps the sub-baseline tail beyond ~10.7 h out of the integral, and Figure Inspector Results reports exact area (34.0482), point count (45), and window peak (x = 2, y = 9.13966).

Positive-only (iAUC) vs signed net integration

Measured traces often cross below their baseline—for example postprandial glucose dipping below fasting level, biphasic action potentials, or detector undershoot after an impulse. The choice between positive-clamped and signed integration depends on whether excursions below b(x) cancel positive signal:

  • Positive-only incremental AUC (clamped at zero): sets yeff(xi)=max(0,yi−bi) at each node inside [xmin,xmax]. Because negative samples clamp to zero rather than cancelling positive lobes, both the reported area and plotted shading show strictly positive excursion above the baseline (as in the unshaded tail past t≈10.7 h above). Notice that if the raw trace steps from above baseline to below baseline across one interval [xk,xk+1], linear nodal clamping uses the trapezoid connecting (xk,yk−bk) and (xk+1,0) rather than solving for the exact zero-crossing root inside the step.
  • Signed net AUC (negative excursions included): keeps the raw difference yeff(xi)=yi−bi with sign intact. Negative deviations subtract directly from positive peaks, which matches conserved quantities whose integral should recover zero when upward and downward fluctuations balance.

Wait until the baseline level itself is verified before toggling negative-area inclusion: setting Constant b0 too high artificially pushes legitimate signal tail below the baseline and hides real exposure if negative area stays clamped.

Sampling bias, curvature, and common AUC traps

Even when discrete formulas match software output to machine precision, four numerical traps distort physical conclusions:

  1. Coarse sampling across sharp maxima and exponential tails: linear segments cut below a concave-down peak and cut above a concave-up elimination decay. As Yeh and Kwan (1978) and Purves (1992) demonstrate on pharmacokinetic concentration curves, linear trapezoidal quadrature slightly overestimates concave-up exponential tails unless log-trapezoidal steps or dense sampling are used, whereas splines can ring across abrupt transitions. Densify acquisition near Tmax rather than trusting coarse linear chords across a narrow spike.
  2. Comparing areas integrated on different windows: AUC1→12 cannot be compared directly against AUC0→24 unless the response has genuinely returned to baseline across both intervals. Fix identical [xmin,xmax] bounds and baseline rules across experimental cohorts.
  3. Integrating heavily sloped curves in log space without noticing: plotting a curve on logarithmic axes does not turn linear trapezoidal AUC into a log-spaced integral. If your curve spans decades in x and y, inspect spacing in natural units first or review log binning before aggregating wide tails.
  4. Assuming raw max equals peak over baseline: Autoplot tracks peak in range as the maximum raw y sample inside [xmin,xmax] (x = 2, y = 9.13966 above), not y−b0. Subtract baseline value explicitly when reporting baseline-corrected peak amplitude.

Comparing Autoplot, GraphPad Prism, OriginPro, and SciPy

All four tools compute composite trapezoidal area reliably, so choose by workflow fit and downstream analysis depth:

ToolMac appBaseline and window handlingBest workflow fit
AutoplotNative Apple siliconZero, Constant, Endpoint Line; positive-only or signed; interpolated [xmin, xmax]Interactive single-curve shaded AUC with peak readout and clean export
GraphPad PrismNative macOSY = 0 or constant baseline with total, net, and peak statisticsPaired pharmacology cohorts with built-in replicate summary tables
OriginProWindows without VMInteractive baseline subtraction and multi-peak batch integrationHigh-throughput spectroscopy and multi-peak area matrices
SciPy / NumPyNative Python CLIArray subtraction y - b with trapezoid and np.interpCustom log-trapezoidal, spline quadrature, and automated pipelines

Keep GraphPad Prism when you need replicate-table PK statistics across many subjects at once, keep OriginPro when processing high-throughput multi-peak spectroscopy batches, and use scipy.integrate.trapezoid or numpy.trapezoid when a pipeline requires custom spline or log-trapezoidal quadrature. Use Autoplot when you want interactive [xmin, xmax] window shading, instant switches between Zero, Constant, and Endpoint Line baselines, and crisp figure composition on macOS without writing plotting boilerplate.

In Autoplot

AUC - Area Under Curve in Autoplot

Autoplot's AUC - Area Under Curve layer (Run Analysis → AUC - Area Under Curve inside any X&Y Plot, Plus — free for 30 days) computes exact interpolated trapezoidal integration locally on your Mac:

  • Inputs (Source & Integration): choose X and Y variables, set xmin and xmax in natural x units (blank bounds default to the full sampled span), pick Zero, Constant (Value), or Endpoint Line, and toggle Include negative area between positive-clamped and signed net summation.
  • Visual overlays (Mark & stroke & Label & legend): toggle Curve, semi-transparent Fill opacity, Baseline line, and vertical Bounds (xmin/xmax) lines with independent colors, widths, and Solid / Dotted / Fine Dotted strokes, plus legend entry labels.
  • Readouts (Figure Inspector → Results): view integrated area, effective range, baseline mode and optional value, negative-area flag, interpolated points used, and raw peak in range (x, y), with one-click copy to clipboard.
  • Where it stops: Autoplot uses unweighted linear trapezoidal summation with nodal positive clamping (max(0,y−b)); exact sub-interval zero-crossing interpolation, piecewise log-trapezoidal rules, spline quadrature, and batch multi-curve AUC summary tables are better handled in a custom scipy.integrate.trapezoid script or dedicated PK table tool.

See features and pricing.

Frequently asked questions

Frequently asked questions
How does Autoplot handle xmin or xmax when it falls between sampled rows?Autoplot sorts finite (X, Y) pairs ascending by x and uses linear interpolation between the two bracketing samples whenever xmin or xmax lies inside [xfirst,xlast]. Bounds outside the sampled x span do not extrapolate beyond the data endpoints.
What is the difference between Endpoint Line and Constant baselines?Constant holds a flat horizontal reference b(x)=b0 across the entire [xmin,xmax] window using your entered numeric Value, whereas Endpoint Line constructs a linear ramp connecting (x0,y0) at the start of the window to (x1,y1) at the end so tilted background drift is removed before integration.
Does Include negative area change how the shaded area looks on the plot?Yes. When Include negative area is off, both the numerical area and the shaded band clamp sub-baseline points to zero so dips below the baseline remain unshaded and contribute zero to the integral. When enabled, sub-baseline excursions subtract from the sum and appear shaded on the opposite side of the baseline.
Is the reported peak in range baseline-subtracted?No. Both peakX and peakY in the card footer and Figure Inspector → Results report the coordinates of the maximum raw regionY point inside [xmin,xmax], so subtract b0 or b(xpeak) manually if you need peak height above baseline.

Sources

Algorithm details (buildAUCResult, finite XY zip-sorting, [xmin, xmax] linear interpolation without endpoint extrapolation, 10−12 x-coordinate deduplication, Zero/Constant/Endpoint Line baselines, nodal positive clamping max(0, y - b) vs signed integration, and raw peakX/peakY) and UI labels (AUC - Area Under Curve, Integration, Include negative area, Mark & stroke, Figure Inspector → Results) were verified directly against Autoplot 2.5.2 source (DataModel.swift, FigureContentView.swift, FigurePlotView.swift, and Autoplot's AUC integration documentation) on 27 November 2026. Reference trapezoidal quadrature documentation uses SciPy's scipy.integrate.trapezoid and NumPy's numpy.trapezoid. Linear vs log-trapezoidal and spline bias analyses draw on K. C. Yeh and K. C. Kwan, "A comparison of numerical integrating algorithms by trapezoidal, Lagrange, and spline approximation," Journal of Pharmacokinetics and Biopharmaceutics 6(1), 79–98 (1978), DOI 10.1007/bf01066064, and R. D. Purves, "Optimum numerical integration methods for estimation of area-under-the-curve (AUC) and area-under-the-moment-curve (AUMC)," Journal of Pharmacokinetics and Biopharmaceutics 20(3), 211–226 (1992), DOI 10.1007/bf01062525; and serial biomedical AUC summary analysis draws on J. N. Matthews, D. G. Altman, M. J. Campbell, and P. Royston, "Analysis of serial measurements in medical research," BMJ 300(6719), 230–235 (1990), DOI 10.1136/bmj.300.6719.230.

Try it on your own data.

Autoplot integrates XY curves locally on your Mac with exact boundary interpolation, Zero, Constant, and Endpoint Line baselines, signed or positive-only area control, and editable shaded plots. Part of Plus (free for 30 days).

Read multi-peak fitting and deconvolution →
Download .dmg

Without Private Cloud Compute · macOS 15–26

Apple silicon · macOS 15 or later · Free plan · Plus free for 30 days · 11 starter AI credits

Send to my Mac

Autoplot runs on a Mac. Send the link to yourself, or open it in the Mac App Store.