Skip to main content

An extension of fabricatio, which brings up the capability to plot dataframe with matplotlib

Project description

fabricatio-plot

MIT License Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

Data visualization, synthetic data generation, and dataframe manipulation for the Fabricatio LLM agent framework.


Installation

pip install fabricatio[plot]
# or
uv pip install fabricatio[plot]

For optional file-format support:

pip install fabricatio[plot,excel]    # Excel I/O
pip install fabricatio[plot,parquet]  # Parquet I/O

Install with all Fabricatio components:

pip install fabricatio[full]

Overview

fabricatio-plot equips LLM agents with tools for matplotlib-based charting, programmatic synthetic data generation, dataframe CRUD operations, and file I/O. Toolboxes expose fine-grained functions agents can call; capabilities wrap them into higher-level LLM-driven workflows.

Key Components

Toolboxes

Low-level tools grouped by domain, exposed to agents via fabricatio-tool's ToolBox.

PlottingToolBox — matplotlib chart construction

Function Description
create_figure(figsize, dpi) Create a new matplotlib Figure
create_subplots(nrows, ncols, figsize) Create a figure with a grid of subplots
plot_line(ax, x, y, ...) Draw a line chart on given axes
plot_bar(ax, categories, values, ...) Draw a vertical bar chart
plot_scatter(ax, x, y, ...) Draw a scatter plot
set_labels(ax, title, xlabel, ylabel) Set title and axis labels
set_legend(ax, location, fontsize) Add a legend to the chart
configure_grid(ax, visible, linestyle, alpha) Configure grid lines
save_plot(fig, save_path, dpi, transparent) Save figure to file

DataSynToolbox — synthetic column generation

Function Description
numeric_column(n_rows, low, high) Uniform-distribution numeric column
normal_column(n_rows, mean, std) Normally distributed numeric column
categorical_column(n_rows, categories) Random categorical column
datetime_column(n_rows, start, end) Random datetime column in a range
text_column(n_rows, prefix) Sequential text column (item_0, item_1, …)
correlated_column(base_series, correlation) Column correlated with an existing series
inject_missing(series, rate) Inject NaN values at a given rate

DataCrudToolbox — dataframe create/read/update/delete

Function Description
create_empty_dataframe(columns, dtypes) Create an empty DataFrame with typed columns
add_computed_column(df, new_column, expression) Add a column via pandas expression
get_row_by_index(df, index_value) Retrieve a single row by index
fill_missing_values(df, column, strategy) Fill NaN with mean, median, mode, or constant
transform_column(df, column, transformation) Apply log, sqrt, square, or normalize
drop_columns(df, columns) Remove specified columns
drop_rows_by_condition(df, condition) Remove rows matching a query condition
rename_column(df, old_name, new_name) Rename a single column
set_index_from_column(df, column, drop) Set the DataFrame index from a column

DataIoToolBox — file-based I/O

Function Description
load_csv(file_path) Read CSV into DataFrame
load_excel(file_path, sheet_name) Read Excel into DataFrame (requires excel extra)
load_parquet(file_path) Read Parquet into DataFrame (requires parquet extra)
save_data(df, file_path, fmt) Save DataFrame as CSV, Excel, or Parquet

Capabilities

Higher-level abstractions that orchestrate toolboxes with LLM reasoning.

  • Plot — aggregates PlottingToolBox, DataCrudToolbox, and DataIoToolBox. The plot(requirement, data, output_spec) method accepts a natural-language requirement and delegates to its toolboxes to produce charts.
  • SynthesizeData — uses LLM to generate structured data from a natural-language description. generate_header() produces column names; generate_csv_data() returns a DataFrame; synthesize_data() handles large datasets by batching parallel generation.

Actions

Concrete fabricatio-core Action implementations ready to wire into task pipelines.

  • MakeCharts — takes a plot requirement (or the task's assembled prompt) and produces a chart, optionally saving to a specified path.
  • MakeSynthesizedData — synthesizes a DataFrame from the task prompt and stores it under the key synthesized_data.
  • SaveDataCSV — saves a DataFrame to a path (given explicitly or determined by the LLM from the task context).

Usage

Toolboxes are stateless and can be called directly:

from fabricatio_plot.toolboxes.plot import create_figure, plot_line, set_labels, save_plot

fig = create_figure(figsize=(10, 4))
ax = fig.subplots()
plot_line(ax, x=[1, 2, 3], y=[4, 5, 6], label="Series A")
set_labels(ax, title="Sample Chart", xlabel="X", ylabel="Y")
save_plot(fig, "output.png")

Capabilities drive LLM-orchestrated workflows:

from fabricatio_plot.capabilities.plot import Plot

handler = Plot()
result = await handler.plot("Create a bar chart of monthly sales from the CSV at data/sales.csv")

Actions plug into Fabricatio task graphs:

from fabricatio_plot.actions.plot import MakeCharts

action = MakeCharts(plot_requirement="Scatter plot of x vs y", chart_save_path="scatter.png")
await action.execute(task)

Dependencies

  • fabricatio-core — core interfaces, configuration, and task model
  • fabricatio-toolToolBox and Handle abstractions
  • matplotlib — chart rendering
  • numpy — array operations
  • pandas — DataFrame manipulation
  • Optional: openpyxl (Excel I/O), pyarrow (Parquet I/O)

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_plot-0.1.13.dev0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_plot-0.1.13.dev0-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_plot-0.1.13.dev0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_plot-0.1.13.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 be28fca807488b5d14a6c474b9c729f75058ad538531b4b020260bd63e41f5ee
MD5 bcc0533efce84fb4889a0127219862f3
BLAKE2b-256 5ba569da8b6044cbe2b0f0f4a3c169623ab7a55ce57c741ddb1592c1994b652b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page