Giniúint graif agus léirshamhluithe
Ar an leathanach seo
Nuashonraithe an 2 Samhain, 2026 bunaithe ar dhoiciméadú OpenAI: éilíonn an uirlis Code Interpreter anois paraiméadar
container(curtha leis i ngach sampla), úsáideann codanna ionchuir téacs an cineálinput_text, agus úsáideann cuardach gréasáin an uirlisweb_search(níl saweb_search_previewach uirlis oidhreachta gan scagairí fearainn anois). Faightear comhaid ghinte trí na feidhmeannafichiers_generesagustelechargeró Cheacht 10. Uaslódáiltear comhaid atá ceangailte le teachtaireachtaí leis an gcuspóiruser_data, rud a mholann OpenAI d’ionchuir mhúnla (File inputs). Foinse: Code Interpreter · Cuardach gréasáin.
Giniúint graif agus léirshamhluithe
Ní íomhá ghinte atá i ngraf a tháirgeann Code Interpreter: is éard atá ann léiriú ar script matplotlib iarbhír a ritear ar do chuid sonraí fíor. Tá tábhacht leis an idirdhealú seo—tá na haiseanna cruinn, meaitseálann na luachanna an comhad, agus is féidir leat iarraidh ar an gcód é a atáirgeadh go háitiúil.
Tá trí leabharlann i gcomhfhad sa choimeádán, agus gach ceann acu ag freastal ar chuspóir difriúil. Déileálann matplotlib le gach rud ach is féidir leis a bheith fada. Cuireann seaborn sraith staitistiúil leis a dhéanann dáileadh agus comhchoibhneas inléite i líne amháin. Cruthaíonn plotly HTML idirghníomhach, rud atá oiriúnach go háirithe do sheachadtaí a scrúdóidh tú leis an luch. Ainmnigh an ceann a theastaíonn uait i do leid; gan treoracha, úsáideann an múnla matplotlib de réir réamhshocraithe.
Graif shimplí le matplotlib
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6-terra",
input="Create a bar chart showing monthly sales: "
"Jan=120, Feb=98, Mar=145, Apr=167, May=189, Jun=210, "
"Jul=195, Aug=178, Sep=220, Oct=245, Nov=267, Dec=312. "
"Professional style, blue colors, title and labels.",
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
instructions="Use matplotlib with a professional style. "
"Sans-serif font, light grid, no top or right spines."
)
# Retrieve the generated image
for ann in fichiers_generes(response):
telecharger(client, ann, "monthly_sales.png")
Graif ó shonraí comhaid
Seo an cás úsáide is coitianta, agus an áit a bhfuil an luach is soiléire: uaslódálann tú an comhad, déanann tú cur síos ar an ngraf a theastaíonn uait, agus déileálann an múnla leis an léamh, le cineálú na gcolún, agus leis an bplotáil. Gan céimeanna ullmhúcháin láimhe, agus go háirithe, gan aon tras-scríobh uimhreacha de láimh—mar sin gan aon earráidí cóipeáil-greamú.
with open("team_performance.csv", "rb") as f:
file_obj = client.files.create(file=f, purpose="user_data")
response = client.responses.create(
model="gpt-5.6-terra",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": (
"From this file, create a dashboard with 4 charts: "
"1. Monthly revenue evolution (line chart) "
"2. Breakdown by product category (pie chart) "
"3. Top 10 clients by revenue (horizontal bar chart) "
"4. Correlation between quantity and amount (scatter plot) "
"Arrange the 4 charts in a 2x2 grid."
)},
{"type": "input_file", "file_id": file_obj.id}
]
}],
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
instructions="Create a matplotlib figure with 4 subplots. "
"Use a consistent color palette. "
"Resolution 1920x1080, DPI 150. "
"Export as high-quality PNG."
)
Léirshamhluithe staitistiúla le seaborn
Bíonn seaborn go hiontach nuair a bhaineann an cheist le dáileadh nó le gaol seachas le sraith luachanna. Nochtann bosca-phlot de réir catagóire nó maitrís chomhchoibhnis ar an toirt an rud nach dtaispeánann tábla uimhreacha ach tar éis léitheoireacht chúramach—agus sin díreach an rud ba chóir do ghraf a dhéanamh.
response = client.responses.create(
model="gpt-5.6-terra",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": (
"Visual statistical analysis of this data: "
"1. Heatmap of the correlation matrix "
"2. Distribution of each numerical variable (histograms + KDE) "
"3. Boxplots by category to identify outliers "
"4. Pairplot of the 5 main variables"
)},
{"type": "input_file", "file_id": file_obj.id}
]
}],
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
instructions="Use seaborn with the 'whitegrid' theme. "
"Annotate values in the heatmap. "
"Use the 'coolwarm' palette for correlations."
)
Graif idirghníomhacha le plotly
Athraíonn plotly nádúr an tseachadta: in ionad íomhá statach, faigheann tú comhad HTML neamhspleách inar féidir leat súmáil, fanacht os cionn pointí, agus scagadh a dhéanamh. Is é an rogha cheart é do dheais a scrúdóidh duine éigin, ach is é an rogha mhícheart é d’fhigiúr atá ceaptha do dhoiciméad clóite nó do ríomhphost.
response = client.responses.create(
model="gpt-5.6-terra",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": (
"Create an interactive plotly chart showing sales evolution with: "
"- Zoom and date range selection "
"- Hover tooltips with details "
"- Buttons to filter by category "
"- Export as standalone HTML file"
)},
{"type": "input_file", "file_id": file_obj.id}
]
}],
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}]
)
# Retrieve the interactive HTML file
for ann in fichiers_generes(response):
if ann.filename.endswith(".html"):
telecharger(client, ann, "interactive_dashboard.html")
Saincheapadh casta
Treoir stíle corparáideach
Tá graf a ghintear de réir réamhshocraithe inaitheanta láithreach agus dealraíonn sé amaitéarach i ndoiciméad corparáideach. Is leor do dhathanna, do chlófhoirne agus do choinbhinsiúin a chur ar fáil in instructions chun figiúirí comhsheasmhacha a tháirgeadh ó thuairisc go tuairisc—agus ós rud é go bhfuil na treoracha seo in-athúsáidte, ní dhéanann tú an iarracht ach uair amháin.
STYLE_GUIDE = """
Visualization rules:
- Primary color: #1E3A5F (navy blue)
- Secondary color: #E74C3C (red)
- Accent color: #F39C12 (orange)
- Background: white (#FFFFFF)
- Font: sans-serif
- No borders around charts
- Light gray grid (#E0E0E0)
- Bold title, size 14
- Axis labels size 11
- Legend at bottom right
- Always include data source at bottom left
- Minimum resolution: 1200x800 pixels
"""
response = client.responses.create(
model="gpt-5.6-terra",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": "Create a quarterly revenue evolution chart"},
{"type": "input_file", "file_id": file_obj.id}
]
}],
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
instructions=STYLE_GUIDE
)
Patrún: gineadóir tuairisce fise
def generate_visual_report(
file_path: str,
report_title: str,
sections: list[str]
) -> list[str]:
"""Generate a report with charts from data."""
with open(file_path, "rb") as f:
file_obj = client.files.create(file=f, purpose="user_data")
images = []
for i, section in enumerate(sections):
response = client.responses.create(
model="gpt-5.6-terra",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": f"Section {i+1} of report '{report_title}': {section}"},
{"type": "input_file", "file_id": file_obj.id}
]
}],
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
instructions=(
"Create a professional chart for this section. "
"Include a descriptive title and relevant annotations. "
"Export as PNG 1200x800 DPI 150."
)
)
for ann in fichiers_generes(response):
name = f"report_section_{i+1}.png"
telecharger(client, ann, name)
images.append(name)
return images
# Usage
charts = generate_visual_report(
"annual_sales.csv",
"2025 Sales Report",
[
"Monthly revenue evolution with trend",
"Sales breakdown by region (map or treemap)",
"Performance comparison by sales rep (grouped bars)",
"Forecasts for the next 3 months (with confidence interval)"
]
)
Leideanna do ghraif ardchaighdeáin
quality_instructions = """
For each chart:
- Choose the chart type best suited to the data
- Use accessible colors (sufficient contrast)
- Avoid 3D charts unless explicitly requested
- Limit pie charts to 6 categories maximum
- Add annotations for important points
- Use appropriate scales (no truncated zero unless justified)
- Always export in high resolution
"""
Príomhphointí
- Tá matplotlib, seaborn, agus plotly ar fáil sa bhosca gainimh
- Cuir do chuid sonraí ar fáil trí
input_filele haghaidh graif bunaithe ar chomhaid fhíor - Sainigh treoir stíle in
instructionsle haghaidh comhsheasmhachta - Faigh íomhánna ginte ó nótaí
container_file_citation, ansin íoslódáil iad tríd an API coimeádáin (feidhmeannafichiers_generesagustelechargeró Cheacht 10) - Ligeann plotly duit deais HTML idirghníomhacha a ghiniúint