I am trying to add labels to my coutour plots, such as, WD1, WD2, WD3, WD4, WD5,…,WD10 for all 10 contours plots. Here as an example, I only added the commands two contour plots.
# My code
import numpy as np
import matplotlib.pyplot as plt
def C2thin1(mx_mesh, sigma_mesh):
return Cthin1(np.column_stack((mx_mesh.ravel(), sigma_mesh.ravel()))).reshape(mx_mesh.shape)
def C2thin2(mx_mesh, sigma_mesh):
return Cthin2(np.column_stack((mx_mesh.ravel(), sigma_mesh.ravel()))).reshape(mx_mesh.shape)
def cage1_contour(C2thin_func, mx_mesh, sigma_mesh, Rstar, dstar):
return e2dPhidE(C2thin_func, mx_mesh, sigma_mesh, Rstar, dstar)
# Define the range of mx and sigma values
mx_values = np.logspace(np.log10(0.01), np.log10(1000), 100)
sigma_values = np.logspace(np.log10(1e-30), np.log10(1e-50), 100)
# Create a meshgrid for contour plotting
mx_mesh, sigma_mesh = np.meshgrid(mx_values, sigma_values)
# Compute contour values for each function
contour_values1 = cage1_contour(C2thin1, mx_mesh, sigma_mesh, Rstar1, dstar1)
contour_values2 = cage1_contour(C2thin2, mx_mesh, sigma_mesh, Rstar2, dstar2)
# Condition to create the contour line
condition_values1 = sen9int(mx_mesh) - contour_values1
condition_values2 = sen9int(mx_mesh) - contour_values2
# Plot the contours
plt.figure(figsize=(10, 10))
contour1 = plt.contour(mx_mesh, sigma_mesh, condition_values1, levels=[0], colors='purple', linewidths=3, label='WD1')
contour2 = plt.contour(mx_mesh, sigma_mesh, condition_values2, levels=[0], colors='blue', linewidths=3, label='WD2')
plt.xscale('log')
plt.yscale('log')
plt.xlabel(r'$m_{chi}$ (GeV)', fontsize=24, fontweight='bold')
plt.ylabel(r'$sigma_{chi n}$ (cm$^2$)', fontsize=24, fontweight='bold')
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.grid(True, which='both', linestyle='--', linewidth=2, color='black')
plt.axhline(y=1e-41, color='black', linestyle='--', linewidth=2)
plt.axvline(x=100.4, color='black', linestyle='--', linewidth=2)
plt.title('Contour Plot', fontsize=24, fontweight='bold')
plt.legend(fontsize=18)
plt.show()
```[enter image description here](https://i.sstatic.net/IrHd2FWk.png)
New contributor
Pooja Bhattacharjee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.