Clean up context with matplotlib style file + mandatory answer fix
Browse filesCONTEXT CLEANUP:
- Create vayuchat.mplstyle file with professional styling
- Replace 21 lines of matplotlib styling with 1 line: plt.style.use('vayuchat.mplstyle')
- Dramatically reduces LLM context clutter for better code generation
SYSTEM PROMPT IMPROVEMENTS:
- Add MANDATORY answer variable section to prevent "no result saved" errors
- Move model selector to sidebar for better UX (no more scrolling to top)
- Add import requirements and plotting best practices
MAJOR CONTEXT REDUCTION:
- 20+ lines of styling boilerplate eliminated
- Cleaner, more focused code templates for LLM
- Professional consistent theming across all plots
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
- new_system_prompt.txt +18 -1
- src.py +1 -22
- vayuchat.mplstyle +21 -0
new_system_prompt.txt
CHANGED
@@ -13,6 +13,10 @@ AVAILABLE LIBRARIES:
|
|
13 |
- statsmodels, scikit-learn (analysis)
|
14 |
- geopandas (geospatial analysis)
|
15 |
|
|
|
|
|
|
|
|
|
16 |
ESSENTIAL RULES:
|
17 |
|
18 |
DATA SAFETY:
|
@@ -34,8 +38,21 @@ BASIC ERROR PREVENTION:
|
|
34 |
- For correlations: check len(data) > 20 before calculating
|
35 |
- Use simple matplotlib plotting - avoid complex visualizations
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
TECHNICAL REQUIREMENTS:
|
38 |
- Save final result in variable called 'answer'
|
39 |
- Use exact column names: 'PM2.5 (µg/m³)', 'WS (m/s)', etc.
|
40 |
- Handle dates with pd.to_datetime() if needed
|
41 |
-
- Round numerical results: round(value, 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
- statsmodels, scikit-learn (analysis)
|
14 |
- geopandas (geospatial analysis)
|
15 |
|
16 |
+
IMPORT REQUIREMENTS:
|
17 |
+
- Always import what you use: import seaborn as sns, import numpy as np
|
18 |
+
- Standard imports are already available: pandas as pd, matplotlib.pyplot as plt
|
19 |
+
|
20 |
ESSENTIAL RULES:
|
21 |
|
22 |
DATA SAFETY:
|
|
|
38 |
- For correlations: check len(data) > 20 before calculating
|
39 |
- Use simple matplotlib plotting - avoid complex visualizations
|
40 |
|
41 |
+
PLOTTING BEST PRACTICES:
|
42 |
+
- Check data exists in each category before plotting
|
43 |
+
- For comparisons (>, <): ensure both categories have data
|
44 |
+
- Example: high_wind = df[df['WS'] > 3]; low_wind = df[df['WS'] <= 3]
|
45 |
+
- If category is empty: create simple bar chart instead of box plots
|
46 |
+
- Add data count labels: plt.text() to show sample sizes
|
47 |
+
|
48 |
TECHNICAL REQUIREMENTS:
|
49 |
- Save final result in variable called 'answer'
|
50 |
- Use exact column names: 'PM2.5 (µg/m³)', 'WS (m/s)', etc.
|
51 |
- Handle dates with pd.to_datetime() if needed
|
52 |
+
- Round numerical results: round(value, 2)
|
53 |
+
|
54 |
+
MANDATORY: ALWAYS END CODE WITH ANSWER ASSIGNMENT
|
55 |
+
- Every code block MUST end with: answer = [result]
|
56 |
+
- If analysis fails: answer = "Unable to complete analysis with available data"
|
57 |
+
- If plotting fails: answer = "Unable to generate visualization"
|
58 |
+
- NEVER leave answer variable unset - this will cause system failure
|
src.py
CHANGED
@@ -252,28 +252,7 @@ import uuid
|
|
252 |
import calendar
|
253 |
import numpy as np
|
254 |
# Set professional matplotlib styling
|
255 |
-
plt.
|
256 |
-
'font.size': 12,
|
257 |
-
'figure.dpi': 400,
|
258 |
-
'figure.facecolor': 'white',
|
259 |
-
'axes.facecolor': 'white',
|
260 |
-
'axes.edgecolor': '#e2e8f0',
|
261 |
-
'axes.linewidth': 1.2,
|
262 |
-
'axes.labelcolor': '#374151',
|
263 |
-
'axes.spines.top': False,
|
264 |
-
'axes.spines.right': False,
|
265 |
-
'axes.spines.left': True,
|
266 |
-
'axes.spines.bottom': True,
|
267 |
-
'axes.grid': True,
|
268 |
-
'grid.color': '#f1f5f9',
|
269 |
-
'grid.linewidth': 0.8,
|
270 |
-
'grid.alpha': 0.7,
|
271 |
-
'xtick.color': '#6b7280',
|
272 |
-
'ytick.color': '#6b7280',
|
273 |
-
'text.color': '#374151',
|
274 |
-
'figure.figsize': [12, 6],
|
275 |
-
'axes.prop_cycle': plt.cycler('color', ['#3b82f6', '#ef4444', '#10b981', '#f59e0b', '#8b5cf6', '#06b6d4'])
|
276 |
-
}})
|
277 |
df = pd.read_csv("AQ_met_data.csv")
|
278 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
279 |
states_df = pd.read_csv("states_data.csv")
|
|
|
252 |
import calendar
|
253 |
import numpy as np
|
254 |
# Set professional matplotlib styling
|
255 |
+
plt.style.use('vayuchat.mplstyle')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
df = pd.read_csv("AQ_met_data.csv")
|
257 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
258 |
states_df = pd.read_csv("states_data.csv")
|
vayuchat.mplstyle
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# VayuChat Professional Style
|
2 |
+
font.size: 12
|
3 |
+
figure.dpi: 400
|
4 |
+
figure.facecolor: white
|
5 |
+
axes.facecolor: white
|
6 |
+
axes.edgecolor: #e2e8f0
|
7 |
+
axes.linewidth: 1.2
|
8 |
+
axes.labelcolor: #374151
|
9 |
+
axes.spines.top: False
|
10 |
+
axes.spines.right: False
|
11 |
+
axes.spines.left: True
|
12 |
+
axes.spines.bottom: True
|
13 |
+
axes.grid: True
|
14 |
+
grid.color: #f1f5f9
|
15 |
+
grid.linewidth: 0.8
|
16 |
+
grid.alpha: 0.7
|
17 |
+
xtick.color: #6b7280
|
18 |
+
ytick.color: #6b7280
|
19 |
+
text.color: #374151
|
20 |
+
figure.figsize: 12, 6
|
21 |
+
axes.prop_cycle: cycler('color', ['3b82f6', 'ef4444', '10b981', 'f59e0b', '8b5cf6', '06b6d4'])
|