Skip to main content

LLM-powered chart generation Python SDK — create charts with natural language

Project description

License GitHub Python Version

llmpic

Natural Language Chart Generation Python SDK

中文(chinese)


from llmpic import llmPIC

lp = llmPIC(api_key="sk-...", base_url="https://api.openai.com/v1")

# Describe it. Get a chart.
lp.plot("30-day CPU usage trend").show()   # Jupyter inline display
lp.plot("CPU usage trend").save()           # → ~/llmpic_charts/

💡 Why llmpic?

Traditionally, creating charts in Python means wrestling with matplotlib's verbose API — plt.subplots(), ax.set_xticklabels(), fig.tight_layout() — hundreds of functions to memorize, dozens of lines for a single chart. Data scientists spend more time googling matplotlib syntax than analyzing data.

llmpic brings Python charting into the LLM era. For data scientists, analysts, quantitative researchers — anyone who needs charts from data — just describe what you want in plain language and get production-quality matplotlib charts instantly.

Traditional matplotlib llmpic
Lines of code 15–40 lines 1–3 lines
API knowledge 100+ functions 0 (natural language)
Chart types Manual selection 11 types + auto-detect
Iteration Rewrite entire block result.edit("...")
Jupyter plt.show() only result.show() inline
Multi-format Separate savefig calls Single save()
Error recovery Manual debugging Auto-fix with LLM

✨ Features

  • 🗣️ Natural Language Input — describe charts in plain English, Chinese, Japanese, or Korean
  • 📊 11 Chart Types — Line, Scatter, Bar, Pie, Histogram, Heatmap, Boxplot, Area, Radar, Subplots, Auto-detect
  • 📓 Jupyter Inlineresult.show() renders charts directly below notebook cells
  • Async BatchAsyncllmPIC.batch() generates multiple charts concurrently
  • 🔧 Auto-Fix — failed code executions are auto-corrected by the LLM (up to 2 rounds)
  • ✏️ Iterative Editingresult.edit("make bars red") refines charts with natural language
  • 📦 Multi-Format — single save() with extension auto-detection (PNG/SVG/PDF), defaults to home directory
  • 🌍 Multi-Language Labels — auto-detects query language and matches chart labels (zh/ja/ko/en)
  • 🛡️ Dual Safety — 31 precompiled regex patterns + optional LLM semantic review
  • 💻 Cross-Platform — Windows / Linux / macOS, automatic CJK font configuration

📦 Installation

pip install llmpic          # minimal
pip install llmpic[full]    # + pandas, seaborn, scikit-learn

Requires Python ≥ 3.10 and an OpenAI-compatible API endpoint (OpenAI, Azure, DeepSeek, etc.).

📖 Documentation

Document Description
API Reference Complete class, method, and parameter reference
User Guide Advanced usage, best practices, troubleshooting
中文文档 Full documentation in Chinese
Jupyter Demos Ready-to-run Jupyter notebooks

🚀 Quick Start

from llmpic import llmPIC

lp = llmPIC(
    api_key="sk-your-key",
    base_url="https://api.openai.com/v1",
    model="gpt-4o",
)

# Basic — one line, one chart
lp.plot("12-month sales trend").save("sales.png")

# With data & style
import pandas as pd
df = pd.read_csv("sales.csv")
lp.bar("Sales by region").data(df).style({
    "color_scheme": "warm",
    "figsize": [12, 7],
}).save("bar.png")

# Jupyter inline display
lp.plot("CPU usage trend").render().show()

# SVG / PDF export
lp.plot("trend").save("chart.svg")
lp.plot("trend").save("chart.pdf")

# Iterative editing
r = lp.plot("Quarterly sales: Q1=100,Q2=150").render()
r.edit("change to bar chart, red").edit("title 'Annual Report'").show()

# Default save path (no argument → home directory)
lp.plot("simple trend").save()  # → ~/llmpic_charts/chart_{timestamp}.png

Async Batch

from llmpic import AsyncllmPIC
import asyncio

async def main():
    lp = AsyncllmPIC(api_key="sk-...", base_url="https://api.openai.com/v1")

    results = await lp.batch([
        ("plot",     "12-month national sales trend"),
        ("bar",      "Sales comparison by region"),
        ("pie",      "Market share distribution"),
        ("scatter",  "Customer age vs spend"),
        ("heatmap",  "Correlation matrix"),
    ])

    for i, r in enumerate(results):
        r.save(f"chart_{i}.png")

asyncio.run(main())

📊 Chart Types

Method Type
.plot() Line
.scatter() Scatter
.bar() Bar
.pie() Pie
.hist() Histogram
.heatmap() Heatmap
.boxplot() Boxplot
.area() Area
.radar() Radar
.subplots() Dashboard
.custom() Auto-detect

📄 License

MIT © 2026 ADW-19

Project details


Download files

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

Source Distribution

llmpic-0.2.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

llmpic-0.2.1-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file llmpic-0.2.1.tar.gz.

File metadata

  • Download URL: llmpic-0.2.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmpic-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0556e2b7110bd25b13e35d38f2ca91a57b9c6deb5456c1d4abde514da6d5512d
MD5 8fd3e952acc2421227bb7bedc7f615be
BLAKE2b-256 17354a0eb1cbaa4ab029d2263cf57b97573c4967afe85422206c8facf5dc8ee1

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmpic-0.2.1.tar.gz:

Publisher: publish.yml on ADW-19/llmpic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmpic-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: llmpic-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmpic-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c45be58aae4a7ffb43835b7717045523cd6d634228c7c00b866af9ac644d8d2
MD5 f1a0b140fd3c38b7d09a47cc9f433930
BLAKE2b-256 baa84388566d90d725bf679cbab3db9b41fc7cfc225971d5cd7815b44c6d0828

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmpic-0.2.1-py3-none-any.whl:

Publisher: publish.yml on ADW-19/llmpic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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