I want to plot a scientific title or legend label which is e^(x*10**b).
Here's an example:
import matplotlib.pyplot as plt
data = 5.55e10
plt.title('e$^{%.2e}$'%(data))
I want to plot a scientific title or legend label which is e^(x*10**b).
Here's an example:
import matplotlib.pyplot as plt
data = 5.55e10
plt.title('e$^{%.2e}$'%(data))
On
you can do that by extracting the base and exp:
import matplotlib.pyplot as plt
from math import log10, floor
def find_exp_base(number):
exp = floor(log10(abs(number)))
return round(number/10**exp, 2), exp
data = 5.55e10
base, exp = find_exp_base(data)
plt.title('e$^{' + str(base) + '*10^{'+ str(exp) + '}}$')
plt.show()
output :
Split the formatted string and format them again:
Output in matplotlib: