Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install vivekkarmarkar-claude-code-os-skills-plot-juliagit clone https://github.com/VivekKarmarkar/claude-code-os.gitcp claude-code-os/SKILL.MD ~/.claude/skills/vivekkarmarkar-claude-code-os-skills-plot-julia/SKILL.md# Plot Julia — Plot Data from a Julia File
Take a `.jl` file containing data (arrays, ODE solutions, or any plottable variables) and generate a plot using `Plots.jl`. **Nothing more.** No solving, no analysis, no computation beyond what's needed to extract plottable arrays.
## Arguments
`<path to .jl file>` — **Required.** Path to a Julia file containing data to plot.
Examples:
- `/plot-julia solve_exponential_growth.jl`
- `/plot-julia path/to/my_data.jl`
- `/plot-julia` — no args, look for a `.jl` file with data in conversation context or working directory
## What This Skill Does
Takes an existing `.jl` file that produces data and generates a new `.jl` file that:
1. Reproduces the data (copies problem + solve, or data arrays)
2. Adds `using Plots`
3. Calls `plot()` with appropriate labels, title, axis labels, and styling
4. Saves to `.png` with `savefig()`
**That is ALL.** Do not analyze the data. Do not fit curves. Do not compute statistics. Just plot.
## Reference Examples
Read the reference examples in `reference-examples/` before generating any output:
- `reference-examples/plot_exponential_growth.jl` — Single curve (scalar ODE solution)
- `reference-examples/plot_lotka_volterra.jl` — Multiple curves (system ODE solution)
**Match their structure exactly.**
## Workflow
### Step 1: Locate the source file
- If a path is provided as an argument, use that file.
- If no path is provided, check:
1. Was a `.jl` file recently generated in this conversation (e.g., by `/ode-solve-julia`)? Use that.
2. Is there a `.jl` file in the current working directory with plottable data? Use that.
3. If multiple candidates exist, ask which one.
4. If none found, tell the user: "No data file found. Provide a `.jl` file with data to plot."
### Step 2: Read and understand the source file
Read the source `.jl` file and identify:
- **What are the plottable variables?** Look for: `sol` (ODE solution), arrays, vectors, matrices
- **How many curves?** Scalar → one curve. System → one curve per component. Multiple arrays → one curve per array.
- **What are meaningful axis labels?** Infer from variable names and context (e.g., `sol.t` → "t", population model → "Population")
- **What is a good title?** Infer from the header comment or equation
### Step 3: Generate the plot file
Create a new `.jl` file named `plot_<source_name>.jl` (stripping any `solve_` prefix).
#### Structure:
```julia
# =============================================================================
# Plot: <Description>
# =============================================================================
#
# Source: <source_filename>.jl
# Data: <what's being plotted>
#
# =============================================================================
using OrdinaryDiffEq # only if source uses it
using Plots
# --- Data source (from source file) ---
<copy everything needed to produce the data>
# --- Extract components (if needed) ---
<extract arrays from sol, etc.>
# --- Plot ---
plot(x, y,
label = "...",
xlabel = "...",
ylabel = "...",
title = "...",
linewidth = 2,
legend = :topleft,
size = (700, 450),
dpi = 150
)
# --- Save ---
savefig("<descriptive_name>.png")
println("Plot saved: <descriptive_name>.png")
```
### Step 4: Run the file
```bash
julia --pkgimages=no plot_<name>.jl
```
Verify the println confirms the file was saved. Then read the `.png` to show the user.
## Plot Styling Defaults
Always use these unless the user specifies otherwise:
| Property | Value |
|-------------|----------------|
| `linewidth` | `2` |
| `size` | `(700, 450)` |
| `dpi` | `150` |
| `legend` | `:topleft` or `:topright` (whichever avoids the curves) |
| `marker` | `:circle` for sparse data (< 20 points), none for dense |
| `markersize` | `4` when markers are used |
### Multiple Curves
- First curve: `plot(...)` — solid line
- Additional curves: `plot!(...)` — use `linestyle = :dash`, `:dot`, `:dashdot` to differentiate
- Each curve gets a distinct `label`
### System ODE Solutions
Extract components from `sol.u` (which is a vector of vectors):
```julia
t = sol.t
u1 = [sol.u[i][1] for i in eachindex(sol.u)]
u2 = [sol.u[i][2] for i in eachindex(sol.u)]
```
Do NOT use `sol[1,:]` indexing — it requires the `DiffEqArray` interface which may not always be available. The comprehension approach always works.
## Data Types This Skill Handles
| Source Data | How to Plot |
|------------|-------------|
| ODE solution (`sol`) | `plot(sol.t, sol.u)` for scalar; extract components for systems |
| Two arrays `x, y` | `plot(x, y)` |
| Single array `y` | `plot(y)` (index as x-axis) |
| Matrix columns | `plot(x, M[:, i])` for each column |
| Multiple named arrays | One `plot()` per array, overlaid with `plot!()` |
## File Naming
The output file is always named `plot_<base_name>.jl`:
- Input: `solve_exponential_growth.jl` → Output: `plot_exponential_growth.jl`
- Input: `solve_lotka_volterra.jl` → Output: `plot_lotka_volterra.jl`
- Input: `my_data.jl` → Output: `plot_my_data.jl`
Strip the `solve_` prefix if present to avoid `plot_solve_`.
The saved image uses the base name: `exponential_growth.png`, `lotka_volterra.png`, etc.
## Rules
1. **Input is a `.jl` file with data.** If no valid file exists, stop and tell the user.
2. **ONLY plot.** No analysis, no curve fitting, no statistics, no additional computation.
3. **Read reference examples before generating.** Match their structure exactly.
4. **Use `Plots.jl` with the GR backend.** It's installed and works on this system.
5. **Run the file after generating.** Use `julia --pkgimages=no`. Verify the `.png` was saved.
6. **Show the plot to the user.** After running, use the Read tool to display the `.png`.
7. **The output file is self-contained.** It must run independently — includes all data generation, not just the plot call.
8. **Use the comprehension pattern for ODE system components.** `[sol.u[i][k] for i in eachindex(sol.u)]` — always works.