ANALYSIS TOOL BOX

Calculus

PlotFunction

Plot a real-valued function of a single variable over a numeric range.

calculusderivativesintegralsoptimization

Introduction

Before you trust a model or a derived quantity, it helps to see how it behaves — where it rises, flattens, peaks, or breaks down — rather than reason about it purely from an equation. PlotFunction answers "what does this relationship actually look like across its input range?" by rendering any callable as a clean, presentation-ready line plot over a chosen interval. Reach for it when you need to expose non-linear features — plateaus, inflection regions, thresholds — that raw numbers or a symbolic expression alone can obscure, whether you're validating a model or communicating its shape to a non-technical audience.

Teaching Note

Plotting a function reveals qualitative features — curvature, growth rate changes, local maxima/minima, and boundaries — in ways that raw numerical output cannot. Visual inspection remains a cornerstone of analytic sense-making across disciplines.

Parameters

ParameterTypeDefaultDescription
f_of_xrequiredThe function of x to plot.
minimum_xint-10The minimum value of x to use when plotting the function.
maximum_xint10The maximum value of x to use when plotting the function.
nint100The number of points to use when plotting the function.
line_colorstr'#3269a8'The color of the function plot line.
line_alphafloat0.8The alpha (transparency) of the function plot line.
markersstr'o'The marker style to use for the function plot.
x_axis_variable_namestr'x'The label for the x-axis.
y_axis_variable_namestr'f(x)'The label for the y-axis.
title_for_plotstr'Function Plot'The title for the plot.
subtitle_for_plotstr'Shows the function of x'The subtitle for the plot.
caption_for_plotstrNoneThe caption for the plot.
data_source_for_plotstrNoneThe data source for the plot.
x_indentfloat-0.127The x-indent for the x-axis label.
title_y_indentfloat1.125The y-indent for the title.
subtitle_y_indentfloat1.05The y-indent for the subtitle.
caption_y_indentfloat-0.3The y-indent for the caption.
figure_sizetuple(8, 5)The size of the plot figure.

Returns

None — the function displays a plot.

Example

python
from analysistoolbox.calculus import PlotFunction

# Plot f(x) = x^2 over the default range
PlotFunction(
    f_of_x=lambda x: x**2,
    minimum_x=-10,
    maximum_x=10,
    title_for_plot="Function Plot",
    subtitle_for_plot="Shows the function of x",
)