Instructions for generating Python charts with matplotlib, seaborn and Plotly: right chart for the question, labelled axes with units, accessible colors, layouts and reproducible output.
GEMINI.md. Downloaded files need to be placed in that repository path.## Gemini Data Visualization
Applies to: **/*
When generating data visualization code in Python:
## Choose the library and chart
- matplotlib for static, publication-style figures and full control; seaborn for statistical plots built on matplotlib (distributions, relationships, categorical comparisons); Plotly (`plotly.express` first) for interactive charts in notebooks or web pages.
- Pick the chart from the question: trends over time → line; comparison across categories → bar (sorted, starting at zero); distribution → histogram, box or violin; relationship → scatter (add a trend line only if meaningful); part-to-whole with few parts → stacked bar rather than pie.
- Ask which output is needed (notebook, PNG/SVG file, HTML) if the request does not say.
## matplotlib conventions
- Use the object-oriented API: `fig, ax = plt.subplots(...)`, then call methods on `ax`. Use `layout="constrained"` (or `fig.tight_layout()`) so labels do not overlap.
```python
import matplotlib.pyplot as plt
import pandas as pd
def plot_monthly_revenue(df: pd.DataFrame, path: str) -> None:
fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
for region, group in df.groupby("region"):
ax.plot(group["month"], group["revenue"], marker="o", label=region)
ax.set(title="Monthly revenue by region", xlabel="Month", ylabel="Revenue (USD)")
ax.legend(title="Region")
fig.savefig(path, dpi=200)
plt.close(fig)
```
## Labels, titles and annotations
- Every chart has a title that states what is shown, axis labels with units, and readable tick labels (rotate or abbreviate long ones; format numbers with thousands separators or percent).
- Add a legend only when there is more than one series; label lines directly when there are few.
- Annotate the specific points the reader should notice (peaks, launches, outliers) instead of adding gridlines and decoration.
## Color
- Use colorblind-safe palettes (seaborn's `"colorblind"`, matplotlib's `viridis`/`cividis` for continuous data). Do not rely on color alone: vary markers or line styles, or label directly.
- Use a diverging palette only when values have a meaningful midpoint.
## Layouts
- Use subplots with shared axes (`sharex=True`, `sharey=True`) for small multiples; keep scales identical when panels are compared.
## Output and documentation
- Write a function that takes a DataFrame and returns the figure or saves it, so it can be re-run. Close figures in loops (`plt.close(fig)`).
- State the data source, any filtering or aggregation, and units in a docstring or caption.
Project context for Gemini Code Assist agent mode and Gemini CLI: how to respond, what finished code includes, and how to verify changes before proposing them.
System instructions for Gemini on React 19 + TypeScript: typed function components, accessible markup with useId, error boundaries, measured performance and review checklists.
Generate configuration handling code
Gemini
data-science
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
An analyst asks Gemini for a revenue chart from a DataFrame with month, region and revenue columns, to paste into a slide.
Create a chart comparing monthly revenue for each region from df (columns: month, region, revenue in USD). Save it as revenue.png for a slide.
A function using fig, ax = plt.subplots(layout='constrained') that draws one line per region with markers, a descriptive title, axis labels with units (Revenue (USD)), a legend titled Region (or direct labels), a colorblind-safe palette, savefig at a stated dpi and plt.close(fig).
Gemini CLI loads instructional context from GEMINI.md files: a global ~/.gemini/GEMINI.md, files in your workspace directories and their parents, and files discovered in subfolders as the agent works. The file name is configurable, so a project can tell Gemini CLI to read AGENTS.md instead of, or alongside, GEMINI.md. The rules in this directory are written as plain system instructions, so the same text can also be used as a system instruction in Gemini API or Google AI Studio requests.
GEMINI.mdStarting point, not a tested configuration for your repository. GEMINI.md has no file-scoping front matter; add this as a section, or place a GEMINI.md in the relevant subfolder. Review the instructions, adapt the file paths and run your project's existing checks.
## Gemini Data Visualization
Applies to: **/*
When generating data visualization code in Python:
## Choose the library and chart
- matplotlib for static, publication-style figures and full control; seaborn for statistical plots built on matplotlib (distributions, relationships, categorical comparisons); Plotly (`plotly.express` first) for interactive charts in notebooks or web pages.
- Pick the chart from the question: trends over time → line; comparison across categories → bar (sorted, starting at zero); distribution → histogram, box or violin; relationship → scatter (add a trend line only if meaningful); part-to-whole with few parts → stacked bar rather than pie.
- Ask which output is needed (notebook, PNG/SVG file, HTML) if the request does not say.
## matplotlib conventions
- Use the object-oriented API: `fig, ax = plt.subplots(...)`, then call methods on `ax`. Use `layout="constrained"` (or `fig.tight_layout()`) so labels do not overlap.
```python
import matplotlib.pyplot as plt
import pandas as pd
def plot_monthly_revenue(df: pd.DataFrame, path: str) -> None:
fig, ax = plt.subplots(figsize=(8, 4), layout="constrained")
for region, group in df.groupby("region"):
ax.plot(group["month"], group["revenue"], marker="o", label=region)
ax.set(title="Monthly revenue by region", xlabel="Month", ylabel="Revenue (USD)")
ax.legend(title="Region")
fig.savefig(path, dpi=200)
plt.close(fig)
```
## Labels, titles and annotations
- Every chart has a title that states what is shown, axis labels with units, and readable tick labels (rotate or abbreviate long ones; format numbers with thousands separators or percent).
- Add a legend only when there is more than one series; label lines directly when there are few.
- Annotate the specific points the reader should notice (peaks, launches, outliers) instead of adding gridlines and decoration.
## Color
- Use colorblind-safe palettes (seaborn's `"colorblind"`, matplotlib's `viridis`/`cividis` for continuous data). Do not rely on color alone: vary markers or line styles, or label directly.
- Use a diverging palette only when values have a meaningful midpoint.
## Layouts
- Use subplots with shared axes (`sharex=True`, `sharey=True`) for small multiples; keep scales identical when panels are compared.
## Output and documentation
- Write a function that takes a DataFrame and returns the figure or saves it, so it can be re-run. Close figures in loops (`plt.close(fig)`).
- State the data source, any filtering or aggregation, and units in a docstring or caption.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The Gemini CLI documentation states that Gemini CLI was replaced by Antigravity CLI on June 18, 2026 for unpaid-tier and Google One users. Check which CLI your account uses; Antigravity rules are covered on the Antigravity page. Gemini CLI does not need a separate AGENTS.md mechanism: its context file name is configurable through context.fileName in settings.json (the docs show ["AGENTS.md", "CONTEXT.md", "GEMINI.md"]). Without that setting it looks for GEMINI.md.
Documentation checked 2026-11-05: Gemini CLI docs: GEMINI.md context filesGemini CLI docs: System prompt override
Project context for Gemini Code Assist agent mode and Gemini CLI: how to respond, what finished code includes, and how to verify changes before proposing them.
System instructions for Gemini on React 19 + TypeScript: typed function components, accessible markup with useId, error boundaries, measured performance and review checklists.
Generate configuration handling code