A weak chart hides the story; a great one makes it impossible to miss. AI can produce excellent visualisation code in any of the major Python libraries — if you tell it what the data is, who the audience is, and what the chart needs to say. This topic gives you the prompt patterns to consistently get presentation-ready charts on the first try.
Most data scientists know enough Matplotlib to produce a chart, but not enough to produce a good one. The difference shows up in the small things: clear axis labels, sensible tick intervals, colour-blind safe palettes, an annotated headline value, and a subtitle that summarises the takeaway. AI can handle all of that — usually faster than you can — but only if the prompt names the headline insight the chart should communicate. This tutorial shows you how to brief AI like a design editor briefs a junior designer.
A good visualisation prompt answers five questions: what data, what library, what chart type, what story, and what audience. If any of those are missing, the output is generic. Beginners often skip "what story" — and so produce technically correct charts that fail to land with stakeholders. Always state the headline takeaway you want the chart to support: "show that churn rises sharply for plan_type=basic after month 3" is far more useful than "plot churn over time".
It helps to think of a chart as a sentence. Data is the vocabulary, the chart type is the grammar, and the story is the meaning. AI can construct fluent sentences quickly, but it needs you to choose the meaning.
The library choice changes the prompt. Matplotlib is the workhorse — verbose but flexible, ideal for paper figures and notebook artefacts. Seaborn wraps Matplotlib with statistical defaults — perfect for EDA. Plotly produces interactive HTML — ideal for dashboards and stakeholder-facing reports. Always name the library at the top of the prompt so the AI doesn't waste tokens explaining choices.
Weak prompt
Plot my sales data.
No DataFrame, no library, no chart type, no story. The AI returns a generic line chart with default styling, unlabelled axes, no title, and colours that won't pass an accessibility check.
Stronger prompt
Act as a senior data analyst preparing a board-ready chart
in Seaborn (Matplotlib backend).
DataFrame: orders_df with columns
order_date (datetime64), region (str: NA|EU|APAC),
net_revenue_gbp (float64).
Chart goal: show that EU revenue overtook NA revenue
in Q3 of the current year and is now widening the gap.
Requirements:
- Line chart, x = month, y = net_revenue_gbp, hue = region.
- Aggregate by month (pd.Grouper, freq='MS') then sum.
- Title: "EU overtakes NA in Q3 — gap widening into Q4".
- Annotate the crossover point with an arrow + month label.
- Use a colour-blind safe palette (Okabe-Ito).
- Despine top and right.
- Output figsize=(10, 5). Save as 'eu_overtake.png' at 200 dpi.
- Return only the code.
You will receive a Seaborn lineplot with a hand-picked palette, a meaningful title, an ax.annotate call placing an arrow at the crossover, and a clean plt.savefig. Drop it straight into a deck.
The pattern is: DataFrame brief → library → chart type → story → styling rules → output target. The story line is the one most people forget; without it, AI produces a chart, not an argument. Once you make the chart's narrative explicit, the AI starts choosing annotations, titles, and emphasis colours that support that narrative.
For Plotly, add one more constraint: state whether you want a plotly.express one-liner (fast EDA) or a plotly.graph_objects figure (more control, dashboard-ready). For Matplotlib, mention whether axes should follow the journal/paper style (grid off, serif font) or the slide-deck style (bold title, larger fonts).
savefig or fig.write_html accordingly.Tip: Keep a "house style" prompt fragment that lists your preferred palette, font, despine settings, and figsize. Paste it at the top of every visualisation prompt and your charts will look consistent across an entire report deck.
Pick a DataFrame from your work. Pick a single insight you want to communicate. Write three different prompts asking AI to visualise that insight in Matplotlib, Seaborn, and Plotly. Compare which one produces the cleanest output for your story.
Take an existing ugly chart from your portfolio. Paste the code into AI with the prompt:
Critique this chart for clarity and accessibility, then rewrite it. Improvements should include: clearer title summarising the insight, colour-blind safe palette, larger axis labels, despined frame, and an annotation highlighting the key data point.
Build a small Plotly dashboard prompt: "In Plotly, create a 2x2 subplot dashboard showing monthly revenue (line), revenue by region (bar), order count distribution (histogram), and churn rate over time (line). Share the x-axis where appropriate. Use plotly.subplots and a single colour theme." See how much of a working dashboard you get from a single prompt.
Sign in to join the discussion and post comments.
Sign inPrompt Engineering for Content & Copywriting
Write blogs, ads, emails, and social media content ten times faster with AI. 13 practical tutorials on prompt engineering for content creators and copywriters.
Prompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Advanced Prompt Engineering Techniques
Master the powerful techniques AI experts use every day. Chain-of-thought, RAG, agents, function calling, prompt evaluation, and much more — 20 deep-dive tutorials.
Foundations of Prompt Engineering
The must-know basics of prompt engineering. Learn what prompts are, how AI models read them, and how to write clear instructions that get great results.
Prompt Engineering Projects & Real-World Applications
Twelve hands-on projects that turn prompt engineering theory into a portfolio. Build chatbots, content generators, RAG systems, and more.
Prompt Engineering for Specific AI Tools
Tool-by-tool mastery — deep dives into ChatGPT, Claude, Gemini, GitHub Copilot, Midjourney, Stable Diffusion, and more. Learn the exact prompting techniques each platform rewards.