I have the following code here:
import pandas as pd
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import matplotlib.colors
from simple-colors import *
fig, ax = plt.subplots(1, 2, figsize = (8, 8))
ax[0].set_title('Deaths from Cancer in Michigan, 2020',pad=13,fontweight='bold',color='navy')
ax[1].set_title('Deaths from COVID-19 in Michigan, 2020',pad=13,fontweight='bold',color='navy')
ax[0].set_ylabel('Number of cases',labelpad=6,color='brown')
ax[1].set_ylabel('Number of cases',labelpad=6,color='brown')
ax[0].set_xlabel('Month',labelpad=6,color='brown')
ax[1].set_xlabel('Month',labelpad=6,color='brown')
ax[0].plot(COVID19['month'], COVID19['Cases'], color='green', marker='o', linestyle='dashed',linewidth=2, markersize=12)
ax[1].plot(Deaths['month'], Deaths['Cases'], color='red', marker='o', linestyle='dashed',linewidth=2, markersize=12)
ax[0].tick_params(axis='x', labelsize=10,rotation=45)
ax[1].tick_params(axis='x', labelsize=10,rotation=45)
ax[0].tick_params(axis='y', labelsize=10)
ax[1].tick_params(axis='y', labelsize=10)
Deaths = Deaths['Cases'].reset_index()
Deaths = Deaths.drop(['index'],axis=1)
fig.subplots_adjust(bottom=0.2)
Correlation = Deaths['Cases'].corr(COVID19['Cases'],method='pearson')
This gives me the output:
I would like to add text to this figure:
fig.text(0.3,0.05,'Pearsons Correlation Coefficient is {}'.format(Correlation))
This gives me the output:
However, I want to make part 'Pearsons Correlation Coefficient' bold and underlined.
I have tried:
fig.text(0.3,0.05,"Pearson's Correlation Coefficient is: " + r"$\bf\underline{" + str(Correlation) + "}$")
But this gives me the error:
RuntimeError: Failed to process string with tex because latex could not be found
Could anyone give me a helping hand?