I'm trying to plot a histogram with the ticklabel_format style as scientific. But, I want the tick mark to appear as a power of 10, not 1e-2. Is there any way I can make the 1e-2 appear as 10^-2?
P.S.: I'm using this for the first time. So please point out any mistakes or ways to improve my code. Thanks in advance.
Code:
import matplotlib.pyplot as plt
time0=[]
with open("dist20_M500.dat") as f:
for line in f:
time0.append(float(line))
num_bins = 30
# the histogram of the data
n, bins, patches = plt.hist(time0, num_bins, density = True,
edgecolor='black', histtype='bar',facecolor='red', label = '$N=20$')
plt.xlabel(r'Time', fontsize=18)
plt.ylabel(r'$P(t)$', fontsize=18)
plt.legend()
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
plt.ticklabel_format(style='sci', axis='both', scilimits=
(0,0),fontsize=20)
plt.ticklabel_format(useOffset=False)