'plt doesn't change xticks, yticks, xlabel and ylabel to bold
I am trying to convert xticks, yticks, xlabel and ylabel to bold, but nothing work. I attached a screenshot of the output graph.
# visualize the loss as the network trained
fig = plt.figure(figsize=(5,5))
plt.plot(range(1,len(All_end_eopch_training_loss)+1),All_end_eopch_training_loss, label='Training Loss')
plt.plot(range(1,len(All_end_eopch_validation_loss)+1),All_end_eopch_validation_loss,label='Validation Loss')
# find position of lowest validation loss
minposs = All_end_eopch_validation_loss.index(min(All_end_eopch_validation_loss))+1
plt.axvline(minposs, linestyle='--', color='r',label='Early Stopping Checkpoint')
mod_size = 20
plt.xlabel('epochs',fontsize=mod_size, fontweight='bold')
plt.ylabel('loss', fontsize=mod_size, fontweight='bold')
plt.ylim(0,0.3) # consistent scale
plt.xlim(0, len(All_end_eopch_training_loss)+1) # consistent scale
plt.xticks(fontsize=mod_size)
plt.yticks(fontsize=mod_size)
plt.grid(True)
plt.legend(fontsize=10)
plt.tight_layout()
plt.show()
fig.savefig(f'LOSS_ACC_Files/{tensor_baord_variable}_loss_plot.pdf',format="pdf", dpi= 400, bbox_inches='tight')
Solution 1:[1]
I think you used LaTeX for all text in a figure. Perhaps you have set matplotlib.rc('text', usetex=True) before.
You can change xticks, yticks, xlabel and ylabel to bold by doing something like:
plt.rc('xtick', weight = 'bold')
plt.rc('ytick', weight = 'bold')
plt.xlabel(r'\textbf{epochs}')
plt.ylabel(r'\textbf{loss}')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ka-Wa Yip |

