Spaces:
Runtime error
Runtime error
Upload graphs.py
Browse files
graphs.py
CHANGED
|
@@ -102,17 +102,18 @@ def create_addiction_gauge_chart(result):
|
|
| 102 |
ax.plot([needle_angle, needle_angle], [0, 1.2], 'k-', linewidth=4, label=f'Your Score: {predicted_score:.1f}')
|
| 103 |
ax.plot(needle_angle, 1.2, 'ko', markersize=10, markeredgecolor='white', markeredgewidth=2)
|
| 104 |
ax.set_title(f'Addiction Score Gauge\nPredicted: {predicted_score:.1f}/10',
|
| 105 |
-
fontsize=
|
| 106 |
ax.set_xticks([])
|
| 107 |
ax.set_yticks([])
|
| 108 |
ax.set_ylim(0, 1.3)
|
| 109 |
-
|
| 110 |
-
ax.text(np.pi
|
| 111 |
-
ax.text(np.pi, 1.4, '
|
|
|
|
| 112 |
if 'confidence' in result:
|
| 113 |
confidence = result['confidence']
|
| 114 |
ax.text(0, -0.3, f'Confidence: {confidence:.2f}', ha='center', va='center',
|
| 115 |
-
fontsize=
|
| 116 |
plt.tight_layout()
|
| 117 |
img_buffer = io.BytesIO()
|
| 118 |
plt.savefig(img_buffer, format='png', dpi=300, bbox_inches='tight')
|
|
|
|
| 102 |
ax.plot([needle_angle, needle_angle], [0, 1.2], 'k-', linewidth=4, label=f'Your Score: {predicted_score:.1f}')
|
| 103 |
ax.plot(needle_angle, 1.2, 'ko', markersize=10, markeredgecolor='white', markeredgewidth=2)
|
| 104 |
ax.set_title(f'Addiction Score Gauge\nPredicted: {predicted_score:.1f}/10',
|
| 105 |
+
fontsize=8, fontweight='bold', pad=10)
|
| 106 |
ax.set_xticks([])
|
| 107 |
ax.set_yticks([])
|
| 108 |
ax.set_ylim(0, 1.3)
|
| 109 |
+
# Flip the gauge by adjusting text positions and angles
|
| 110 |
+
ax.text(np.pi, 1.4, 'Low\n(1-3)', ha='center', va='center', fontsize=6, fontweight='bold')
|
| 111 |
+
ax.text(np.pi/2, 1.4, 'Moderate\n(3-7)', ha='center', va='center', fontsize=6, fontweight='bold')
|
| 112 |
+
ax.text(0, 1.4, 'High\n(7-10)', ha='center', va='center', fontsize=6, fontweight='bold')
|
| 113 |
if 'confidence' in result:
|
| 114 |
confidence = result['confidence']
|
| 115 |
ax.text(0, -0.3, f'Confidence: {confidence:.2f}', ha='center', va='center',
|
| 116 |
+
fontsize=6, fontweight='bold', bbox=dict(boxstyle="round,pad=0.3", facecolor="lightblue"))
|
| 117 |
plt.tight_layout()
|
| 118 |
img_buffer = io.BytesIO()
|
| 119 |
plt.savefig(img_buffer, format='png', dpi=300, bbox_inches='tight')
|