User Tools

Site Tools


visualization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
visualization [2025/05/30 13:57] – [Example 2: Single Metric Plot] eagleeyenebulavisualization [2025/05/30 13:59] (current) – [Best Practices] eagleeyenebula
Line 144: Line 144:
  
 <code> <code>
-```python+python
 # Extended visualization # Extended visualization
 metrics = { metrics = {
Line 157: Line 157:
 plt.grid(color="gray", linestyle="--", linewidth=0.5) plt.grid(color="gray", linestyle="--", linewidth=0.5)
 plt.show() plt.show()
-```+
 </code> </code>
  
Line 165: Line 165:
  
 <code> <code>
-```python+python
 # Invalid metrics format to simulate failure # Invalid metrics format to simulate failure
 metrics = { metrics = {
Line 173: Line 173:
  
 Visualization.plot_metrics(metrics) Visualization.plot_metrics(metrics)
-```+
 </code> </code>
  
 **Expected Log**: **Expected Log**:
 <code> <code>
-```+
 `ERROR:root:Failed to plot metrics: object of type 'NoneType' has no len() ` `ERROR:root:Failed to plot metrics: object of type 'NoneType' has no len() `
-``` +
 </code> </code>
  
Line 190: Line 190:
  
 <code> <code>
-```python+python
 for key, values in metrics.items(): for key, values in metrics.items():
     plt.plot(values, label=key, linestyle="--", marker="o", color="red")     plt.plot(values, label=key, linestyle="--", marker="o", color="red")
-```+
 </code> </code>
  
Line 201: Line 201:
  
 <code> <code>
-```python+python
 plt.savefig("metrics_plot.png", dpi=300) plt.savefig("metrics_plot.png", dpi=300)
 logging.info(f"Metrics plot saved to metrics_plot.png") logging.info(f"Metrics plot saved to metrics_plot.png")
-```+
 </code> </code>
  
Line 211: Line 211:
 Embed the plotted visualizations into a web dashboard using tools such as **Dash** or **Flask**: Embed the plotted visualizations into a web dashboard using tools such as **Dash** or **Flask**:
 <code> <code>
-```python+python
 import io import io
 from flask import Flask, Response from flask import Flask, Response
Line 228: Line 228:
 if __name__ == "__main__": if __name__ == "__main__":
     app.run(debug=True)     app.run(debug=True)
-```+
 </code> </code>
  
Line 234: Line 234:
  
 1. **Label Your Plots**: 1. **Label Your Plots**:
-   Always provide meaningful titles, axis labels, and legends to improve readability.+   Always provide meaningful titles, axis labels, and legends to improve readability.
  
 2. **Validate Data Inputs**: 2. **Validate Data Inputs**:
-   Ensure that all metric keys and values are properly structured before invoking `plot_metrics()`.+   Ensure that all metric keys and values are properly structured before invoking `plot_metrics()`.
  
 3. **Modular Designs**: 3. **Modular Designs**:
-   Extend and customize utility functions without modifying the core `Visualization` class directly.+   Extend and customize utility functions without modifying the core `Visualization` class directly.
  
 4. **Optimize for Scaling**: 4. **Optimize for Scaling**:
-   For handling large datasets, reduce the number of points or smooth values to improve performance.+   For handling large datasets, reduce the number of points or smooth values to improve performance.
  
 ===== Conclusion ===== ===== Conclusion =====
visualization.1748613478.txt.gz · Last modified: 2025/05/30 13:57 by eagleeyenebula