Improve plot resolution and add CSV download functionality
Browse files- Increased plot DPI from 300 to 600 for ultra-high resolution
- Enhanced matplotlib style with larger figure size (14x8)
- Added explicit high-DPI settings in code generation template
- Fixed CSV download for dataframes in Streamlit interface
- Updated system prompt with high-resolution plotting instructions
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
- app.py +15 -0
- new_system_prompt.txt +2 -2
- src.py +10 -1
- vayuchat.mplstyle +7 -6
app.py
CHANGED
|
@@ -481,7 +481,22 @@ def show_custom_response(response):
|
|
| 481 |
</div>
|
| 482 |
""", unsafe_allow_html=True)
|
| 483 |
|
|
|
|
| 484 |
st.dataframe(content, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
|
| 486 |
# Show generated code with Streamlit expander
|
| 487 |
if response.get("gen_code"):
|
|
|
|
| 481 |
</div>
|
| 482 |
""", unsafe_allow_html=True)
|
| 483 |
|
| 484 |
+
# Display dataframe with download option
|
| 485 |
st.dataframe(content, use_container_width=True)
|
| 486 |
+
|
| 487 |
+
# Add download button for CSV
|
| 488 |
+
import io
|
| 489 |
+
csv_buffer = io.StringIO()
|
| 490 |
+
content.to_csv(csv_buffer, index=False)
|
| 491 |
+
csv_data = csv_buffer.getvalue()
|
| 492 |
+
|
| 493 |
+
st.download_button(
|
| 494 |
+
label="📥 Download as CSV",
|
| 495 |
+
data=csv_data,
|
| 496 |
+
file_name=f"vayuchat_data_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv",
|
| 497 |
+
mime="text/csv",
|
| 498 |
+
use_container_width=True
|
| 499 |
+
)
|
| 500 |
|
| 501 |
# Show generated code with Streamlit expander
|
| 502 |
if response.get("gen_code"):
|
new_system_prompt.txt
CHANGED
|
@@ -33,8 +33,8 @@ DATA SAFETY:
|
|
| 33 |
- Use .dropna() to remove missing values before analysis
|
| 34 |
|
| 35 |
PLOTTING REQUIREMENTS:
|
| 36 |
-
- Create plots for visualization requests: plt.figure(figsize=(
|
| 37 |
-
- Save plots: filename = f"plot_{uuid.uuid4().hex[:8]}.png"; plt.savefig(filename, dpi=
|
| 38 |
- Close plots: plt.close()
|
| 39 |
- Store filename: answer = filename
|
| 40 |
- For non-plots: answer = "text result"
|
|
|
|
| 33 |
- Use .dropna() to remove missing values before analysis
|
| 34 |
|
| 35 |
PLOTTING REQUIREMENTS:
|
| 36 |
+
- Create plots for visualization requests: plt.figure(figsize=(14, 8))
|
| 37 |
+
- Save plots with ultra-high resolution: filename = f"plot_{uuid.uuid4().hex[:8]}.png"; plt.savefig(filename, dpi=600, bbox_inches='tight', facecolor='white', edgecolor='none')
|
| 38 |
- Close plots: plt.close()
|
| 39 |
- Store filename: answer = filename
|
| 40 |
- For non-plots: answer = "text result"
|
src.py
CHANGED
|
@@ -254,8 +254,17 @@ import seaborn as sns
|
|
| 254 |
import uuid
|
| 255 |
import calendar
|
| 256 |
import numpy as np
|
| 257 |
-
# Set professional matplotlib styling
|
| 258 |
plt.style.use('vayuchat.mplstyle')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
df = pd.read_csv("AQ_met_data.csv")
|
| 260 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
| 261 |
states_df = pd.read_csv("states_data.csv")
|
|
|
|
| 254 |
import uuid
|
| 255 |
import calendar
|
| 256 |
import numpy as np
|
| 257 |
+
# Set professional matplotlib styling with high DPI
|
| 258 |
plt.style.use('vayuchat.mplstyle')
|
| 259 |
+
# Additional high-resolution settings
|
| 260 |
+
plt.rcParams['figure.dpi'] = 600
|
| 261 |
+
plt.rcParams['savefig.dpi'] = 600
|
| 262 |
+
plt.rcParams['font.size'] = 14
|
| 263 |
+
plt.rcParams['axes.titlesize'] = 16
|
| 264 |
+
plt.rcParams['axes.labelsize'] = 14
|
| 265 |
+
plt.rcParams['xtick.labelsize'] = 12
|
| 266 |
+
plt.rcParams['ytick.labelsize'] = 12
|
| 267 |
+
plt.rcParams['legend.fontsize'] = 12
|
| 268 |
df = pd.read_csv("AQ_met_data.csv")
|
| 269 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
| 270 |
states_df = pd.read_csv("states_data.csv")
|
vayuchat.mplstyle
CHANGED
|
@@ -12,11 +12,11 @@ xtick.labelsize: 11
|
|
| 12 |
ytick.labelsize: 11
|
| 13 |
legend.fontsize: 11
|
| 14 |
|
| 15 |
-
# Figure & DPI
|
| 16 |
-
figure.dpi:
|
| 17 |
figure.facecolor: white
|
| 18 |
figure.edgecolor: none
|
| 19 |
-
figure.figsize:
|
| 20 |
figure.autolayout: True
|
| 21 |
|
| 22 |
# Modern Color Palette (inspired by Tailwind/GitHub)
|
|
@@ -84,9 +84,10 @@ patch.force_edgecolor: False
|
|
| 84 |
text.color: 1f2937
|
| 85 |
text.antialiased: True
|
| 86 |
|
| 87 |
-
# Savefig
|
| 88 |
-
savefig.dpi:
|
| 89 |
savefig.facecolor: white
|
| 90 |
savefig.edgecolor: none
|
| 91 |
savefig.bbox: tight
|
| 92 |
-
savefig.pad_inches: 0.2
|
|
|
|
|
|
| 12 |
ytick.labelsize: 11
|
| 13 |
legend.fontsize: 11
|
| 14 |
|
| 15 |
+
# Figure & DPI - Ultra High Resolution
|
| 16 |
+
figure.dpi: 600
|
| 17 |
figure.facecolor: white
|
| 18 |
figure.edgecolor: none
|
| 19 |
+
figure.figsize: 14, 8
|
| 20 |
figure.autolayout: True
|
| 21 |
|
| 22 |
# Modern Color Palette (inspired by Tailwind/GitHub)
|
|
|
|
| 84 |
text.color: 1f2937
|
| 85 |
text.antialiased: True
|
| 86 |
|
| 87 |
+
# Savefig - Ultra High Resolution
|
| 88 |
+
savefig.dpi: 600
|
| 89 |
savefig.facecolor: white
|
| 90 |
savefig.edgecolor: none
|
| 91 |
savefig.bbox: tight
|
| 92 |
+
savefig.pad_inches: 0.2
|
| 93 |
+
savefig.format: png
|