Introduction¶
grplot introduces powerful features through an intuitive, hierarchical argument system. Every feature is directly accessible via plot2d parameters, allowing you to configure everything from high-level data inputs to the finest label details in a single function call.
Understanding the Argument System¶
Arguments in grplot are processed at four different levels of granularity:
Ordinary arguments — Apply to the entire figure (e.g.,
df,figsize,Nx).Axes arguments — Apply to specific subplots (e.g.,
plot,filter,title).Axes-plot arguments — Apply to specific plots within a subplot (e.g.,
zorder).Axes-axislabel arguments — Apply to specific axes and labels (e.g.,
lim,sep).
💡 Global Rule: The X and Y Counterparts
To reduce repetition, almost all axes-axislabel arguments (like sep, lim, log, dt, tick_add, label_add, statdesc, text, rot) apply to both axes by default.
You can easily target a specific axis by prefixing the argument with x or y. (Example: lim sets both limits; xlim sets only the x-axis limit; ylim sets only the y-axis limit.)
Argument Syntax Guide¶
Depending on the hierarchical level of the argument, grplot allows you to target specific subplots or layers using dictionary mapping. Below is the syntax guide showing how to assign a value (represented by return) to an argument (arg).
Note
A 1-row figure uses a 1D axes index:
'[i]'(e.g.,'[1]').A multi-row figure uses a 2D axes index:
'[i,j]'(e.g.,'[1,1]').Important: Axes arguments start from 1 (unlike pure matplotlib, which starts from 0).
Ordinary argument:
arg = return
Axes arguments:
arg = return
arg = {'[i,j]': return}
arg = {return: '[i,j]'}
arg = {return: ['[i,j]']}
Axes-plot arguments:
arg = return
arg = {'plot': return}
arg = {'[i,j]': {'plot': return}}
arg = {'[i,j]': {return: 'plot'}}
arg = {'[i,j]': {return: ['plot']}}
arg = {'[i,j]': return}
arg = {return: 'plot'}
arg = {return: ['plot']}
Axes-axislabel arguments:
arg = return
arg = {'axislabel': return}
arg = {'[i,j]': {'axislabel': return}}
arg = {'[i,j]': {return: 'axislabel'}}
arg = {'[i,j]': {return: ['axislabel']}}
arg = {'[i,j]': return}
arg = {return: 'axislabel'}
arg = {return: ['axislabel']}
Core Data & Plot Setup¶
These parameters define what you are plotting and the data behind it.
Parameter |
Argument Level |
Input |
Description |
|---|---|---|---|
|
Axes |
e.g., |
Plot type |
|
Ordinary |
pandas.DataFrame, dict of lists, or dict of numpy.ndarray |
Input data source |
|
Ordinary |
str, list, numpy.ndarray, pandas.Index, or None; returns key(s) mapping to |
Input variable(s) |
|
Axes |
Pandas query string or boolean pandas.Series |
Data filtering prior to plotting |
Figure & Subplot Layout¶
Control the grid structure and spacing of your overall figure. All are Ordinary arguments.
Parameter |
Input |
Default |
Description |
|---|---|---|---|
|
int (grid size) or |
Dynamic |
Grid columns (Nx) / rows (Ny). Defaults: Nx = max(Nx, Ny) if ≤ 2 else 2. Ny = 1 if max(Nx, Ny) ≤ 2 else ceil(max/2). |
|
list/tuple of two numbers |
|
Figure dimensions: Width, height in inches. |
|
numeric |
|
Outer padding between figure edge and subplots (fraction of font size). |
|
numeric |
|
Inner padding height/width between adjacent subplots. |
Axis Controls & Scales¶
Fine-tune the behavior of your x and y axes. All are Axes-axislabel arguments. (Remember: prefix with x or y to target a single axis).
Parameter |
Input |
Default |
Description |
|---|---|---|---|
|
|
None |
Axis limit. |
|
|
None |
Axis scale. |
|
strftime date format (e.g., |
None |
Datetime format using Python’s standard strftime formats. |
|
float (degrees) |
None |
Tick rotation in degrees. |
Formatting & Units¶
grplot provides powerful built-in string manipulation for numbers and labels. (Remember: prefix with x or y to target a single axis).
Number formatting uses the sep argument. Patterns may include separators, currency, and large-number abbreviations.
Pattern |
Meaning |
Example |
|---|---|---|
|
Thousand separator |
|
|
Currency-style formatting (adds trailing zeros) |
|
|
Large-number abbreviation (K, M, B, T, Q) |
|
|
Currency + abbreviation |
|
Unit patterns are specified separately for ticks and labels:
Parameter |
Input |
Effect |
|---|---|---|
|
|
Prefix/suffix value with unit |
|
|
Wrap negatives in parentheses: |
|
|
Add unit to axis label itself |
Annotations & Statistics¶
Easily layer text and statistical descriptions over your data.
Parameter |
Argument Level |
Description |
|---|---|---|
|
Axes-axislabel |
Statistical summaries added to the plot. Combine using |
|
Axes-axislabel |
Data annotations (see details below). Prefix with |
|
Axes |
Explicit axis labels (str). Overrides |
|
Axes |
Plot/Subplot title (str). |
Text argument details:
Type & default:
bool/str/None(defaultNone).Both axes by default: apply to x‑ and y‑axes unless prefixed with
xory.When `bool`: toggles automatic labels on points/bars. Used by scatterplot, lineplot, pieplot, treemapsplot, packedbubblesplot, and residplot.
When `str`: specifies base position(s) using
'h'(horizontal),'v'(vertical),'i'(inside), or'o'(outside). Accepts a single position or a combination separated by+(e.g.,'h+i'). Used by histplot, barplot, countplot, and paretoplot.
Available statdesc Returns:
Grouped:
'general','boxplot'Central & Spread:
'mean','median','std','range','min','max'Counts:
'count','nonzero','unique'Quartiles & Bounds:
'q1','q3','pct1','pct5','pct95','pct99','whislo','whishi','cilo','cihi'
Styling, Typography & Drawing Order¶
Control the aesthetic elements of the plot. All font parameters belong to the Axes level.
Parameter |
Input |
Default |
Description |
|---|---|---|---|
|
numeric |
|
Base font size. Acts as the fallback for all text. |
|
numeric |
|
Specific sizing for: tick, legend, text, label, or title. |
|
str |
|
Legend position; valid keywords include:
|
Performance & Export¶
Manage system resources and save your output. Both are Ordinary arguments.
Parameter |
Input |
Default |
Description |
|---|---|---|---|
|
str |
|
|
|
str or None |
|
Save figure as |