The values which I entered s1 to st is on y axis that is flame intensity and the X axis plot a linearity curve
mkdir -p /tmp/workspace/linearity-curve && python3 << 'EOF' import matplotlib.pyplot as plt import matplotlib.patches as mpatches import numpy as np # Data extracted from the image samples = ['S1', 'S2', 'S3', 'S4', 'S5'] x = [1, 2, 3, 4, 5] # Sample numbers on X-axis flame_intensity = [3, 5, 4, 9, 11] # Observations (Y-axis) # Linear regression / trend line coeffs = np.polyfit(x, flame_intensity, 1) poly = np.poly1d(coeffs) x_line = np.linspace(0.5, 5.5, 100) y_line = poly(x_line) # R-squared y_mean = np.mean(flame_intensity) ss_tot = sum((yi - y_mean)**2 for yi in flame_intensity) ss_res = sum((yi - poly(xi))**2 for yi, xi in zip(flame_intensity, x)) r_squared = 1 - ss_res / ss_tot fig, ax = plt.subplots(figsize=(8, 6)) # Plot data points ax.scatter(x, flame_intensity, color='royalblue', s=100, zorder=5, label='Observed Data') # Connect data points with a line ax.plot(x, flame_intensity, color='steelblue', linewidth=1.2, linestyle='--', alpha=0.6) # Trend / linearity line ax.plot(x_line, y_line, color='crimson', linewidth=2, label=f'Linearity Fit\ny = {coeffs[0]:.2f}x + {coeffs[1]:.2f}\nR² = {r_squared:.4f}') # Annotate each point for xi, yi, label in zip(x, flame_intensity, samples): ax.annotate(f'{label} ({yi})', xy=(xi, yi), xytext=(xi + 0.1, yi + 0.3), fontsize=10, color='navy') # Labels and formatting ax.set_xlabel('Sample Number (S1 → S5)', fontsize=13) ax.set_ylabel('Flame Intensity', fontsize=13) ax.set_title('Linearity Curve – Flame Intensity vs Samples', fontsize=14, fontweight='bold') ax.set_xticks(x) ax.set_xticklabels(samples, fontsize=11) ax.set_xlim(0.3, 5.7) ax.set_ylim(0, 14) ax.grid(True, linestyle='--', alpha=0.4) ax.legend(fontsize=10, loc='upper left') plt.tight_layout() plt.savefig('/tmp/workspace/linearity-curve/linearity_curve.png', dpi=150, bbox_inches='tight') print("Saved successfully!") print(f"Slope: {coeffs[0]:.4f}, Intercept: {coeffs[1]:.4f}, R²: {r_squared:.4f}") EOF

| Sample | X (Sample No.) | Y (Flame Intensity) |
|---|---|---|
| S1 | 1 | 3 |
| S2 | 2 | 5 |
| S3 | 3 | 4 |
| S4 | 4 | 9 |
| S5 | 5 | 11 |
linearity curve
Image · PNG