Environment:Mbzuai oryx Awesome LLM Post training Python Matplotlib
| Knowledge Sources | |
|---|---|
| Domains | Visualization, Infrastructure |
| Last Updated | 2026-02-08 08:00 GMT |
Overview
Python environment with matplotlib for generating publication trend bar charts as PNG files.
Description
This environment provides the visualization runtime for the research trend analysis pipeline. It includes matplotlib.pyplot for creating bar charts with customized styling (color, font sizes, grid, value labels), saving figures to PNG files, and optionally displaying them interactively via plt.show(). The charts visualize yearly publication counts per research keyword.
Usage
Use this environment when generating publication trend visualizations. It is the mandatory prerequisite for the Matplotlib_Bar_Chart implementation in future_research_data.py.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (Linux, macOS, Windows) | Linux servers may need a non-interactive backend |
| Hardware | Standard CPU | No GPU required |
| Display | Optional | plt.show() requires a display; headless servers use Agg backend automatically |
| Disk | 100MB free | For PNG output files (one per keyword) |
Dependencies
System Packages
- No mandatory system packages
- On headless Linux servers, `libgl1-mesa-glx` or similar may be needed for certain matplotlib backends
Python Packages
- `python` >= 3.6
- `matplotlib` (any recent version)
- `pandas` (for DataFrame input to charts)
Credentials
No credentials required.
Quick Install
# Install all required packages
pip install matplotlib pandas
Code Evidence
Import statement from `scripts/future_research_data.py:6`:
import matplotlib.pyplot as plt
Chart generation from `scripts/future_research_data.py:71-90`:
plt.figure(figsize=(12, 6))
bars = plt.bar(df_counts['Year'], df_counts['Papers Published'], color='#2c7fb8')
plt.title(f'Publication Trend for "{keyword}" ({category})', fontsize=14, pad=20)
plt.xlabel('Year', fontsize=12)
plt.ylabel('Number of Papers', fontsize=12)
plt.xticks(years)
plt.grid(axis='y', linestyle='--', alpha=0.7)
# Add value labels on top of each bar
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'{height:,}', ha='center', va='bottom')
plt.tight_layout()
figure_filename = os.path.join(output_dir, f"Publication_Trend_{keyword.replace(' ', '_')}.png")
plt.savefig(figure_filename)
plt.show()
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ModuleNotFoundError: No module named 'matplotlib'` | matplotlib not installed | `pip install matplotlib` |
| `_tkinter.TclError: no display name` | Running plt.show() on headless server | Set `matplotlib.use('Agg')` before importing pyplot, or remove `plt.show()` calls |
| `UserWarning: FigureCanvasAgg is non-interactive` | Non-interactive backend warning | Safe to ignore; PNG files are still saved correctly |
Compatibility Notes
- Headless servers: On servers without a display (CI/CD, SSH sessions), plt.show() will either raise an error or produce a warning. The PNG files are still saved correctly via plt.savefig(). Set the Agg backend with `matplotlib.use('Agg')` before importing pyplot to suppress warnings.
- Figure sizing: Charts use a fixed 12x6 inch figure size. On high-DPI displays, consider adding `dpi=150` to plt.savefig() for higher resolution output.
- All platforms: Works on Linux, macOS, and Windows.