### Install Frontend Dependencies and Start Development Server Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Navigates to the frontend directory, installs Node.js dependencies using yarn, and starts the development server. The frontend will be available at http://localhost:3000. ```bash cd app yarn install yarn dev ``` -------------------------------- ### Start FastAPI Backend Server Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/commands/start.md Starts the FastAPI backend development server on port 8000. Ensure the `uv` command is available. ```bash uv run uvicorn api.main:app --reload --port 8000 ``` -------------------------------- ### Clone and Install Backend Dependencies Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Clones the Anyplot repository and installs all backend dependencies using uv. A PostgreSQL database and a .env file with DATABASE_URL are required. ```bash git clone https://github.com/MarkusNeusinger/anyplot.git cd anyplot uv sync --all-extras ``` -------------------------------- ### Install Dependencies Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/docs/project-guide.md Installs project dependencies using the uv package manager. Ensure you have uv installed. ```bash uv sync --all-extras ``` -------------------------------- ### Julia Import Example Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/plot-generator.md Example of importing necessary libraries for Julia (Makie) plots. ```julia using CairoMakie using DataFrames using Colors ``` -------------------------------- ### Workflow Integration Example with Prompts Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/docs/project-guide.md An example of how workflows can reference and include prompt content. This demonstrates embedding prompt files directly into a workflow configuration. ```yaml # Example usage in workflow prompt: | $(cat prompts/plot-generator.md) $(cat prompts/library/matplotlib.md) ## Spec $(cat plots/scatter-basic/specification.md) ``` -------------------------------- ### YAML Review Metadata Example Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/plot-generator.md Example of review feedback in YAML format for regenerating implementations. ```yaml # plots/{spec-id}/metadata/{language}/{library}.yaml review: strengths: - "Clean code structure" - "Good color accessibility" weaknesses: - "Font sizes too small for canvas" - "Grid too prominent" ``` -------------------------------- ### Start React Frontend Server Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/commands/start.md Starts the React frontend development server on port 3000. This command changes the directory to 'app' before running. ```bash cd app && yarn dev ``` -------------------------------- ### Validation Commands Example Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/commands/bug.md Examples of commands to validate a bug fix, including running the test suite and checking Python syntax. ```bash uv run pytest tests/ -v ``` ```bash uv run python -m py_compile api/**/*.py ``` -------------------------------- ### SQL Query Optimization Example Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/database.md Example of using EXPLAIN ANALYZE to analyze the performance of a SQL query that joins specs and implementations and counts implementations per spec. ```sql EXPLAIN ANALYZE SELECT s.*, COUNT(i.id) as impl_count FROM specs s LEFT JOIN impls i ON s.id = i.spec_id GROUP BY s.id; ``` -------------------------------- ### Unit Test Example with Mocked DB (New Router) Source: https://github.com/markusneusinger/anyplot/blob/main/tests/README.md Example of writing a unit test for a new router endpoint, demonstrating the use of `patch` to mock database interactions. Use when testing isolated logic. ```python # tests/unit/api/test_new_router.py from unittest.mock import patch def test_endpoint_with_mocked_db(): with patch("api.routers.new.get_db", return_value=None): # Test your endpoint ... ``` -------------------------------- ### Anyplot Scatter Plot Example Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/anyplot-landing-mockup.html Demonstrates a basic scatter plot using the any.plot() function with the 'penguins' dataset. This is a common starting point for data visualization. ```python ap.scatter(penguins) ``` -------------------------------- ### Configure Backend Database Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Copies the example environment file and instructs to edit the DATABASE_URL for PostgreSQL connection. ```bash cp .env.example .env # Edit .env with your DATABASE_URL: # DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/anyplot ``` -------------------------------- ### Get Tag Values for Plot Types Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/mcp.md Fetches all available values for a specified tag category, along with their counts. This example specifically retrieves plot types. ```json { "category": "plot_type", "values": [ {"value": "scatter", "count": 45}, {"value": "bar", "count": 38}, {"value": "line", "count": 32} ] } ``` -------------------------------- ### Import Lets-Plot and Setup Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/library/letsplot.md Import the Lets-Plot library and set up HTML output for notebooks or exports. This is a required first step. ```python from lets_plot import * LetsPlot.setup_html() # Required for notebook/export ``` -------------------------------- ### Local Development Setup for PostgreSQL Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/docs/project-guide.md Steps to set up a local PostgreSQL database connection using SQLAlchemy and asyncpg. Ensure to copy the environment template and edit the DATABASE_URL. ```bash cp .env.example .env # Edit .env with your DATABASE_URL DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/anyplot # Test connection uv run python -c "from core.database import is_db_configured; print(is_db_configured())" ``` -------------------------------- ### Save Bokeh Plot as HTML and PNG Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/library/bokeh.md Provides a comprehensive example for saving a Bokeh plot as an interactive HTML file and a static PNG image using headless Chrome via Selenium. It includes necessary imports, driver setup, and screenshotting logic, emphasizing the importance of matching window size to figure dimensions. ```python import time from pathlib import Path from bokeh.io import output_file, save from selenium import webdriver from selenium.webdriver.chrome.options import Options # Write the interactive HTML (also a required catalog artifact) output_file(f"plot-{THEME}.html") save(p) # Screenshot it with headless Chrome — Selenium 4 / Selenium Manager # auto-resolves a working driver for the system Chrome. # IMPORTANT: W,H must match the figure's width/height above, otherwise the # bokeh canvas paints into the upper-left corner with white space around it. W, H = 3200, 1800 opts = Options() for arg in ( "--headless=new", "--no-sandbox", "--disable-dev-shm-usage", "--disable-gpu", f"--window-size={W},{H}", "--hide-scrollbars", ): opts.add_argument(arg) driver = webdriver.Chrome(options=opts) driver.set_window_size(W, H) driver.get(f"file://{Path(f'plot-{THEME}.html').resolve()}") time.sleep(3) # let bokeh's JS render the canvas driver.save_screenshot(f"plot-{THEME}.png") driver.quit() ``` -------------------------------- ### Build Frontend for Production Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Builds the frontend application for production deployment. ```bash yarn build ``` -------------------------------- ### Python Import Example Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/plot-generator.md Example of importing only necessary libraries for Python plots. ```python import numpy as np import pandas as pd import matplotlib.pyplot as plt ``` -------------------------------- ### Example of Batch Creation Command Source: https://github.com/markusneusinger/anyplot/blob/main/CLAUDE.md This bash command demonstrates how to trigger the bulk generation of implementations for a specific specification ID across all libraries. ```bash gh workflow run bulk-generate.yml -f specification_id= -f library=all ``` -------------------------------- ### Academic Citation Example Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/style-guide.md This is an example of how to cite the Anyplot project in academic contexts. ```text anyplot.ai. (2026). A catalogue of Python plotting examples across multiple libraries. https://anyplot.ai ``` -------------------------------- ### R Import Example Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/plot-generator.md Example of importing necessary libraries for R (ggplot2) plots. ```r library(ggplot2) library(dplyr) library(tidyr) ``` -------------------------------- ### Manual Frontend Deployment Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/docs/project-guide.md Submit a build for the frontend service using Google Cloud Build. ```bash # Frontend gcloud builds submit --config=app/cloudbuild.yaml --project=YOUR_PROJECT_ID ``` -------------------------------- ### Plan, Build, Test, and Review Workflow Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/README.md Executes the full pipeline including planning, building, testing, and reviewing code. ```bash # Plan + Build + Test + Review uv run agentic/workflows/plan_build_test_review.py "add dark mode toggle" ``` -------------------------------- ### Example Impls Row Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/database.md An example row from the 'impls' table, showing tracked library-specific plot implementations. ```json { "id": "550e8400-e29b-41d4-a716-446655440000", "spec_id": "scatter-basic", "library_id": "matplotlib", "code": "import matplotlib.pyplot as plt\n...", "preview_url": "https://storage.googleapis.com/anyplot-images/plots/scatter-basic/matplotlib/plot.png", "preview_html": null, "python_version": "3.13", "library_version": "3.9.0", "quality_score": 92.0, "generated_at": "2025-01-15T10:30:00Z", "generated_by": "claude-opus-4-7", "issue": 42, "workflow_run": 12345678 } ``` -------------------------------- ### Asyncpg Connection Pooling Setup Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/database.md Python code demonstrating how to configure an asyncpg database engine with connection pooling settings, including specifying a custom connection creator. ```python # core/database/connection.py engine = create_async_engine( "postgresql+asyncpg://", async_creator=get_conn, # Cloud SQL Connector pool_size=5, # Connections in pool max_overflow=10, # Additional connections if needed pool_pre_ping=True # Verify connection before use ) ``` -------------------------------- ### Install uv Package Manager Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Installs the uv package manager using a curl script. Ensure you have Python 3.13+. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Configure Cloud SQL Database for Development Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Example of setting the DATABASE_URL for Cloud SQL, requiring your IP to be authorized. ```bash DATABASE_URL=postgresql+asyncpg://user:pass@CLOUD_SQL_PUBLIC_IP:5432/anyplot ``` -------------------------------- ### Data Generation Examples Source: https://github.com/markusneusinger/anyplot/blob/main/prompts/plot-generator.md Examples of generating synthetic data using NumPy for study hours, exam scores, temperatures, and revenue. ```python # Good study_hours = np.random.normal(6, 2, 80) exam_scores = study_hours * 8 + np.random.normal(0, 5, 80) + 30 temperatures = np.array([22.1, 23.5, 25.0, 24.2]) revenue_by_quarter = [1.2e6, 1.5e6, 1.3e6, 1.8e6] ``` ```python # Bad x = np.random.randn(80) y = x * 0.8 + np.random.randn(80) data1 = [1, 2, 3, 4] ``` -------------------------------- ### Alembic Migration File Example Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/database.md A Python snippet illustrating the structure of an Alembic migration file, showing the 'upgrade' and 'downgrade' functions for creating and dropping tables. ```python # migrations/versions/001_initial_schema.py def upgrade(): op.create_table('specs', ...) op.create_table('libraries', ...) op.create_table('impls', ...) def downgrade(): op.drop_table('impls') op.drop_table('libraries') op.drop_table('specs') ``` -------------------------------- ### Step Histogram Data Example Source: https://github.com/markusneusinger/anyplot/blob/main/plots/histogram-stepwise/specification.md Example data format for a step histogram. The 'Value' column should contain numeric, continuous measurements. ```text Value ------ 12.5 18.3 15.7 22.1 24.6 19.2 ... ``` -------------------------------- ### Run Backend Database Migrations Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Applies all database migrations using uv and alembic. Ensure the DATABASE_URL is configured in .env. ```bash uv run alembic upgrade head ``` -------------------------------- ### Configure Local PostgreSQL Database Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Example of setting the DATABASE_URL for a local PostgreSQL instance in the .env file. ```bash DATABASE_URL=postgresql+asyncpg://user:pass@localhost:5432/anyplot ``` -------------------------------- ### Start Backend API Server Source: https://github.com/markusneusinger/anyplot/blob/main/docs/development.md Starts the FastAPI API server in reload mode using uvicorn. The API will be available at http://localhost:8000/docs. ```bash uv run uvicorn api.main:app --reload ``` -------------------------------- ### Manual Backend Deployment Source: https://github.com/markusneusinger/anyplot/blob/main/agentic/docs/project-guide.md Submit a build for the backend service using Google Cloud Build. ```bash # Backend gcloud builds submit --config=api/cloudbuild.yaml --project=YOUR_PROJECT_ID ``` -------------------------------- ### Interact with MCP Tools using Python Client Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/mcp.md This Python snippet demonstrates how to use the MCP client to list available tools and call a specific tool with parameters. Ensure the 'mcp.client' library is installed. ```python from mcp.client import Client async with Client("https://api.anyplot.ai/mcp/") as client: tools = await client.list_tools() print(tools) result = await client.call_tool("list_specs", {"limit": 10}) print(result) ``` -------------------------------- ### Light Theme - Pie Example Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/palette-variants-v3/index.html Illustrates the 'muted-8 hybrid-v3' palette for pie charts (first 4 slices) on a light background. ```text muted-8 hybrid-v3 — pie (first 4) ``` -------------------------------- ### Describe Cloud SQL Instance Tier and Settings Source: https://github.com/markusneusinger/anyplot/blob/main/docs/reference/performance.md Fetches details about a Cloud SQL instance, including its tier, disk size, database version, and activation policy. Useful for verifying instance provisioning. ```bash gcloud sql instances describe anyplot-db \ --format='yaml(settings.tier,settings.dataDiskSizeGb,databaseVersion,settings.activationPolicy)' ``` -------------------------------- ### Step Line Plot Data Example Source: https://github.com/markusneusinger/anyplot/blob/main/plots/line-stepwise/specification.md Example data format for a step line plot, showing discrete changes in 'y' values over an independent 'x' variable. ```text x | y -----|------- 0 | 100 1 | 100 2 | 150 3 | 150 4 | 125 ```