### Frontend Setup and Development Server Source: https://github.com/markusneusinger/pyplots/blob/main/docs/development.md Navigates to the 'app' directory, installs frontend dependencies using Yarn, and starts the React development server. Also includes the command for building the production version. ```bash cd app yarn install yarn dev # → http://localhost:3000 yarn build ``` -------------------------------- ### Backend Setup and API Server Source: https://github.com/markusneusinger/pyplots/blob/main/docs/development.md Clones the Pyplots repository, installs backend dependencies using 'uv sync', configures the database connection via '.env', applies migrations, and starts the FastAPI development server. ```bash git clone https://github.com/MarkusNeusinger/pyplots.git cd pyplots uv sync --all-extras cp .env.example .env # Edit .env with your DATABASE_URL: # DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/pyplots uv run alembic upgrade head uv run uvicorn api.main:app --reload # → http://localhost:8000/docs ``` -------------------------------- ### Install Frontend Dependencies and Start Development Server Source: https://context7.com/markusneusinger/pyplots/llms.txt Installs frontend dependencies using Yarn and starts the development server for the frontend application. This allows for real-time development and testing of the user interface. ```bash # Frontend development cd app yarn install yarn dev # Development server yarn build # Production build ``` -------------------------------- ### Install Dependencies and Run Backend API (Bash) Source: https://github.com/markusneusinger/pyplots/blob/main/CLAUDE.md Installs project dependencies using 'uv' and starts the backend API server using 'uvicorn'. Ensure you have 'uv' and 'uvicorn' installed. ```bash # Install dependencies (uses uv - fast Python package manager) uv sync --all-extras # Start backend API uv run uvicorn api.main:app --reload --port 8000 ``` -------------------------------- ### Install Project Dependencies with uv Source: https://context7.com/markusneusinger/pyplots/llms.txt Installs project dependencies using the 'uv' package manager. The '--all-extras' flag ensures that all optional dependencies are also installed, providing a complete development environment. ```bash # Install dependencies with uv (fast Python package manager) uv sync --all-extras ``` -------------------------------- ### Frontend Development Commands (Bash) Source: https://github.com/markusneusinger/pyplots/blob/main/CLAUDE.md Navigates to the frontend directory, installs dependencies using Yarn, and starts the development server or builds for production. ```bash cd app yarn install yarn dev # Development server yarn build # Production build ``` -------------------------------- ### Seaborn Datasets for Realistic Examples Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/plot-generator.md Illustrates loading realistic, domain-specific datasets using Seaborn. The example shows how to load the 'tips' dataset, which is suitable for demonstrations involving real-world patterns. ```python import seaborn as sns df = sns.load_dataset('tips') # Restaurant tipping data ``` -------------------------------- ### SQL Query Optimization Example Source: https://github.com/markusneusinger/pyplots/blob/main/docs/reference/database.md Illustrates how to use `EXPLAIN ANALYZE` in SQL to analyze and optimize the performance of slow queries. This example shows analyzing a query that joins `specs` and `impls` tables. ```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; ``` -------------------------------- ### Plot Implementation Structure Example Source: https://context7.com/markusneusinger/pyplots/llms.txt Provides an example of the expected structure for plot implementation scripts. It highlights the header comment format containing metadata and demonstrates basic data generation using NumPy for a scatter plot. ```python """ pyplots.ai scatter-basic: Basic Scatter Plot Library: matplotlib 3.10.0 | Python 3.13 Quality: 92/100 | Created: 2025-01-10 """ import matplotlib.pyplot as plt import numpy as np # Data - study hours vs exam scores np.random.seed(42) study_hours = np.random.uniform(1, 12, 120) exam_scores = 45 + study_hours * 4.5 + np.random.randn(120) * 8 exam_scores = np.clip(exam_scores, 0, 100) ``` -------------------------------- ### Start Backend API with Uvicorn Source: https://context7.com/markusneusinger/pyplots/llms.txt Starts the backend API server using Uvicorn. The '--reload' flag enables hot-reloading for development, automatically restarting the server when code changes are detected. The API runs on port 8000. ```bash # Start backend API uv run uvicorn api.main:app --reload --port 8000 ``` -------------------------------- ### Set Up Environment Variables Source: https://context7.com/markusneusinger/pyplots/llms.txt Copies an example environment file to a new file named '.env'. This is a common practice to set up configuration variables for the application, such as database URLs and API keys. ```bash # Set up environment variables cp .env.example .env # Edit .env with your DATABASE_URL and other settings ``` -------------------------------- ### Install uv Package Manager Source: https://github.com/markusneusinger/pyplots/blob/main/docs/development.md Installs the 'uv' package manager, a fast alternative to pip and poetry. This command fetches and executes an installation script from a remote URL. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Test Python Implementation Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/workflow-prompts/impl-repair-claude.md This snippet demonstrates how to activate a virtual environment, navigate to the implementation directory, and run a Python script using a specific backend. It's used to test the implementation after making fixes. ```bash source .venv/bin/activate cd plots/{SPEC_ID}/implementations MPLBACKEND=Agg python {LIBRARY}.py ``` -------------------------------- ### Matplotlib API Compatibility for Boxplots (3.9+) Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/library/matplotlib.md Highlights the change in matplotlib's API for setting labels in boxplots starting from version 3.9. It shows the deprecated method using `labels` and the correct, current method using `tick_labels`. ```python # DEPRECATED: labels in boxplot ax.boxplot(data, labels=group_names) # Wrong # CORRECT: use tick_labels ax.boxplot(data, tick_labels=group_names) # Right ``` -------------------------------- ### Python API Function Documentation Source: https://github.com/markusneusinger/pyplots/blob/main/CLAUDE.md Example of a Python function with Google-style docstrings, including arguments, return values, and potential exceptions. This adheres to the project's Python style guide for API and core code. ```python def get_spec_by_id(spec_id: str, db: Session) -> Spec: """ Retrieve a spec by its ID. Args: spec_id: The unique spec identifier db: Database session Returns: Spec object if found Raises: NotFoundError: If spec doesn't exist """ pass ``` -------------------------------- ### Alembic Database Migration Commands and Python Code Source: https://github.com/markusneusinger/pyplots/blob/main/docs/reference/database.md Demonstrates the use of Alembic for managing database schema migrations. Includes commands for creating new migrations, applying them, and rolling back, along with a Python example of an initial schema migration script. ```bash # Create new migration alembic revision -m "add new column" # Apply migrations alembic upgrade head # Rollback alembic downgrade -1 ``` ```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') ``` -------------------------------- ### Markdown Data Section Format Example with Python Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/spec-validator.md An example of the required format for the 'Data' section in a Markdown specification. It includes a list of required columns with their types and descriptions, and an optional Python code snippet for data example. ```markdown ## Data **Required columns:** - `column_name` (type) - description **Example:** *(optional)* ```python data = pd.DataFrame({...}) ``` ``` -------------------------------- ### Markdown Tags Section Format Example Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/spec-validator.md An example of the required format for the 'Tags' section in a Markdown specification. Tags should be comma-separated and at least two tags are required. ```markdown ## Tags scatter, correlation, basic ``` -------------------------------- ### Import Lets-Plot and Setup HTML Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/library/letsplot.md Imports the necessary components from the lets_plot library and sets up HTML rendering, which is required for notebook environments or exporting plots. ```python from lets_plot import * LetsPlot.setup_html() # Required for notebook/export ``` -------------------------------- ### Python Dataframe Example for Data Section Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/spec-validator.md A Python code snippet demonstrating how to create a Pandas DataFrame, which can be used as an example in the 'Data' section of the plot specification. ```python import pandas as pd data = pd.DataFrame({...}) ``` -------------------------------- ### Spec-Level Tags Example (YAML) Source: https://github.com/markusneusinger/pyplots/blob/main/docs/reference/tagging-system.md An example of Spec-Level tags in YAML format, illustrating how plot type, data type, domain, and features are defined for a scatter plot. ```yaml # plots/scatter-basic/specification.yaml tags: plot_type: - scatter data_type: - numeric - continuous domain: - statistics - general features: - basic - 2d - correlation ``` -------------------------------- ### Local PostgreSQL Database Setup Source: https://github.com/markusneusinger/pyplots/blob/main/CLAUDE.md Commands to set up a local PostgreSQL database connection for the project. It includes copying an environment file, editing the database URL, and testing the connection using uv and Python. ```bash # Copy environment template cp .env.example .env # Edit .env with your DATABASE_URL DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/pyplots # Test connection uv run python -c "from core.database import is_db_configured; print(is_db_configured())" ``` -------------------------------- ### Markdown Description Format Example Source: https://github.com/markusneusinger/pyplots/blob/main/prompts/spec-validator.md An example of the required format for the plot specification's description section in Markdown. It should be 2-4 sentences explaining the plot's purpose, usage, and utility. ```markdown ## Description 2-4 sentences describing what the plot shows, when to use it, and what makes it useful. ``` -------------------------------- ### SQL Inserts for Supported Libraries Source: https://github.com/markusneusinger/pyplots/blob/main/docs/reference/database.md Provides example SQL INSERT statements to populate the 'libraries' table with common plotting libraries like Matplotlib, Seaborn, Plotly, and Altair. ```sql INSERT INTO libraries (id, name, version, documentation_url) VALUES ('matplotlib', 'Matplotlib', '3.9.0', 'https://matplotlib.org'), ('seaborn', 'Seaborn', '0.13.0', 'https://seaborn.pydata.org'), ('plotly', 'Plotly', '5.18.0', 'https://plotly.com/python'), ('altair', 'Altair', '5.2.0', 'https://altair-viz.github.io'); ```