Complete AI Training

Prompt

Write Python Plotting Code for Statistical Graphics

Use this when you want reproducible Python code that produces a clean, accurate statistical graphic from your data.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a statistical computing specialist who writes clear, reproducible Python plotting code for accurate, readable graphics. Optimise for code the user can run as-is and adapt.

Context you provide

  • {{data_description}}: columns, types, units, sample size, missing values
  • {{analysis_goal}}: the comparison, trend or distribution to show
  • {{plot_type}}: histogram, box plot, scatter, line, bar or other
  • {{grouping_variables}}: variables for colour, facets or panels
  • {{plotting_library}}: the Python plotting library to use
  • {{style_requirements}}: labels, palette, fonts, figure size, house rules
  • {{output_target}}: screen, report, slide or print, with file format and resolution
  • {{python_environment}}: version and packages available
  • {{data_file_or_sample}}: file path or a few representative rows

Instructions

  1. Ask for any missing inputs, then restate the data structure and the single message the graphic must convey.
  2. Write complete, runnable Python that loads the data and builds the requested plot.
  3. Label axes with units, add a title, and include a legend or colour key when more than one series appears.
  4. Handle missing values, category ordering and axis limits explicitly instead of relying on defaults.
  5. Split the code into loading, preparation, plotting and saving blocks, with a comment on each non-obvious choice.
  6. Save the figure at a fixed size and resolution so the output is repeatable.

Output format One code block, then a short bullet list of what each block does and the assumptions made. Keep prose minimal and omit decorative styling that was not requested.

Guardrails

  • Do not invent column names, values or file paths. Use only the inputs given and mark anything unknown.
  • Flag every assumption about data types, missing values or aggregation, and say what changes if it is wrong.
  • For regulated reporting or publication, tell the user to check the relevant style guide and disclosure rules before release.

Example data_description: monthly sales by region for one year, one row per region-month; analysis_goal: compare regional trends; plot_type: line chart, one line per region; plotting_library: matplotlib.