Provides plotting tools useful in datascience.
A lightweight plotting library for data science that unifies data transformation and plotting in a single chainable API. dataplot is designed for fast exploration, teaching demos, and script-based analysis workflows.
$ pip install dataplotmatplotlib, numpy, pandas, scipy, seaborn, loggings, validating, lazyrdataplot focuses on an analysis-first plotting workflow: data processing and visual diagnostics are written in one concise chain.
| Capability | What it gives you | Typical API |
|---|---|---|
| π¦ Data-as-object API | Treat raw arrays/series as first-class plotting objects with metadata and settings. | dp.data(...) |
| π Composable transforms | Build reproducible feature pipelines before plotting. | .rolling().demean().zscore().rank() |
| π Statistical chart set | Switch between distribution, trend, and diagnostic views quickly. | .hist(), .plot(), .scatter(), .qqplot() |
| π§© Artist-first composition | Compose multiple plots into one figure in a clean, deferred style. | dp.figure(artist1, artist2, ...) |
| ποΈ Layered settings model | Configure defaults at dataset / axes / figure scope with consistent fallback. | set_plot(), set_axes(), set_figure() |
| π Scientific Python stack | Keep compatibility with familiar numeric and plotting ecosystems. | numpy, pandas, scipy, matplotlib, seaborn |
In short: less boilerplate, clearer analysis flow, and more reusable plotting code.
import dataplot as dp
import numpy as np
raw = np.random.randn(300)
x = dp.data(raw, name="daily_return")
artist1 = x.hist(bins=30, alpha=0.7)
artist2 = x.qqplot(baseline="norm")
fig = dp.figure(artist1, artist2, title="Distribution diagnostics")
figdp.data(...) is the entry point of dataplot.
It converts array-like input (for example list, numpy.ndarray, pandas.Series, or another PlottableData) into a unified PlottableData object.
PlottableData is the core abstraction that carries:
- data values
- transformation history
- plot-level settings (labels, style hints, etc.)
This design keeps analysis context attached to the data itself.
import dataplot as dp
import numpy as np
raw = np.random.randn(300)
x = dp.data(raw, name="daily_return")Raw data -> dp.data(...) -> transform chain -> artist(s) -> dp.figure(...)
You can think of dataplot as a 4-step loop:
- Wrap your data with
dp.data(...). - Transform it with chainable operations (
rolling,zscore,rank, ...). - Render one or more
Artistobjects via plot methods. - Compose artists into a figure and apply final figure/axes settings.
PlottableData supports both arithmetic operators and built-in transforms:
- Arithmetic:
+ - * / ** - Log / power family:
log()/log10()/signedlog()/signedlog10()/pow()/root()/sqrt()/ ... - Statistical transforms:
rolling()/demean()/zscore()/rank(pct=True)/cumsum()/abs() - State management:
copy()/reset()/undo_all()/sample()
Operations are chainable, which is useful for quick experimentation:
x.zscore().rolling(5).rank(pct=True)Every plot method returns an Artist object instead of drawing immediately.
This enables deferred composition and clean multi-panel figure assembly:
- Distribution:
hist(...) - Trend / relationship:
plot(...),scatter(...) - Goodness-of-fit diagnostics:
qqplot(...),ppplot(...),ksplot(...) - Structure overview:
corrmap(...)
artist1 = x.hist(bins=30, alpha=0.7)
artist1 # show one plotartist2 = x.qqplot(baseline="norm")
fig = dp.figure(artist1, artist2, title="Distribution diagnostics")
fig # show both plotsCommon settings:
title,xlabel,ylabelalpha,grid,grid_alphastyle,figsize,dpifontdict,legend_locsubplots_adjustreference_lines(for example:"y=x","y=0","x=1")
This project falls under the BSD 3-Clause License.
- Added
PlottableData.hexbin(...)and fixed hexbin distortion/aspect behavior on non-square axes by using axis-range ratio adjustments. - Enhanced scatter plotting with a fitted trend line option
fit. - Refined histogram fit-curve rendering by aligning fit-line color with histogram bars and darkening the fit curve for clearer contrast.
- Completed plotting style API naming cleanup:
fmtnaming was finalized tolinestyleormarker.
- Added
dp.randn(...)for generating normally distributedPlottableDatavalues, including optional seed-based reproducibility. - Improved line and scatter x-axis rendering by preserving the rightmost tick label, supporting datetime tick lists, and refining default x-label behavior.
- Improved reference-line handling on date-based x-axes, including datetime constants such as
"x=20250101 06:30"and validation for unsupported sloped date-axis expressions. - Smoothed histogram fitted PDF curves by rendering fits on a denser grid when users choose sparse bins.
- Renamed the original count-based
resample()workflow tosample()for clearer semantics, while introducing interval-basedresample(...)for fixed-step data aggregation. - Added
copy=support to data normalization/input handling so callers can control whether input values are copied. - Optimized non-normal histogram fitting by adding a sampling path to improve performance on large datasets.
- Removed the legacy
labelalias fromData/PlottableDatainternals and completed the naming shift tonamefor a more consistent API. - Renamed
normrank()toranknorm()for method-name consistency with existing rank-normalization terminology. - Refined README presentation with updated section icons and clearer visual structure.
- Added rank-normalization support via
PlottableData.ranknorm(...), using normal-quantile mapping for percentile ranks. - Optimized rank computation by vectorizing tie handling in
PlottableData.rank(...). - Completed the naming migration from
PlotDataSet/PlottableDatastoPlottableData/PlottableDataSetfor clearer API consistency. - Refactored
PlottableDataby moving its data-processing logic into a new parent classData, keeping only plotting settings.
- Added arithmetic operator support to
MultiObject(including reflected operators), enabling element-wise math workflows for groupedPlottableDataobjects with length checks. - Improved numerical robustness in
utils.mathby consistently sanitizingNaN/Infinputs and validating finite sample counts in 1D linear regression. - Refined
PlottableData.plot()/PlottableData.scatter()x-tick handling to accept broader array-like inputs and convert them consistently. - Added and expanded unit tests for core/container behavior and utility modules.
- Renamed
dist_or_sample=tobaseline=inPlottableData.qqplot()for clearer baseline specification. - Removed
edge_precision=fromPlottableData.ppplot()andPlottableData.ksplot(), and refined probability-range handling in the related diagnostic plotting flow. - Improved QQ/PP plot readability by updating default axis labels and ensuring the rightmost x-axis tick label is preserved.
- New method
PlottableData.rank(pct=True)for rank transformation, supportingpct=Falseto return raw ranks. - Updated scatter behavior with improved defaults and removed implicit x-axis sorting.
- Refactored plotting APIs to remove the
axconstructor argument for a cleaner artist construction flow.
- Improved naming inference in
dp.data(...)when decorators fromvalidatingare involved. - Refined module exports around artist helpers to make wildcard-style artist imports behave consistently.
- Refactored plot-setting fallback behavior to use
dp.defaultsas the global source of defaults. - Enhanced
get_setting(...)(including overload/type-hint coverage) so default values align with the corresponding setting types, and dict defaults are handled more safely. - Removed legacy
set_default()usage and simplified setting application paths across artists/containers. - Added dependency
loggingsand updated warning emission in figure setting flows.
dp.data(...)can acceptPlottableDataobjects now.FigWrapper.__enter__()now returns a copy safely via_entered_copy.- Internal maintenance and stability refinements.
- New method
PlottableData.scatter()to draw true scatter charts while keepingPlottableData.plot()as line chart behavior. - Improved automatic label inference for
dp.data(...), plotting labels, and x-axis labels in interactive contexts. - Plot builders now use deferred drawing; removed
dp.show()and improved axis/figure rendering in object representations. - Refined rendering stability with fixes for empty-axis cleanup and figure re-rendering in
FigWrapper.__repr__. - Updated minimum required Python version to >=3.13.
- Fixed issue: unworking figure settings in the artist methods.
- Fixed issue: incorrectly displayed histogram statistics when the x-label had been modified by the user.
- Allowed users to set the plot-settings by kwargs in artist methods like
PlottableData.hist(),PlottableData.plot(), etc. - New operation methods
PlottableData.signedpow()andPlottableData.log10(). - Renamed
PlottableData.signlog()to.signedlog(); renamedPlottableData.opclear()to.undo_all(); removedPlottableData.opclear_records_only(). - New optional parameter
format_label=forPlottableData.set_plot()to decide whether to format the label when painting on the axes. - When defining the data classes, used dataclasses instead of attrs for a faster import.
- New methods
PlottableData.corrmap(),PlottableData.ppplot(), andPlottableData.resample(). - New optional parameter
fmt=forPlottableData.plot(),PlottableData.qqplot(),PlottableData.ppplot(), andPlottableData.ksplot(). - Bugfix.
- New module-level function
dp.show(). - New methods
PlottableData.qqplot(),PlottableData.ksplot()andPlottableData.abs(). - All the plotting method (e.g.,
.hist()) will now return anArtistobject instead of None. - New plot settings:
gridandgrid_alpha. - Parameters of
FigWrapper.set_figure(),AxesWrapper.set_axes()andPlottableData.set_plot()are keyword-only now. - The returns of
.set_figure()and.set_axes()will be None (instead ofself) to avoid misunderstandings. - New optional parameter
inplace=forPlottableData.set_plot()to decide whether the changes will happen in-place (which is the only option before) or in a new copy. - Parameter
ticks=forPlottableData.plot()can be set to aPlottableDataobject now.
PlottableDatanow supports binary operations including +, -, *, /, and **.- New methods
FigWrapper.set_figure()andAxesWrapper.set_axes()- use them instead of*.set_plot(). - Simplified the usage of
AxesWrapper. - New plot settings:
subplots_adjust=,fontdict=anddpi=. - After this version, the required Python version is updated to >=3.11.9. Download and install v0.0.2 if the user is under lower Python version (>=3.8.13).
- Updated the meta-data.
- Initial release.