尝试使用python3中的代码绘制weibull分布(
http://www.astroml.org/book_figures/chapter3/fig_weibull_distribution.html
)
import numpy as np
from scipy.stats import dweibull
from matplotlib import pyplot as plt
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)
k_values = [0.5, 1, 2, 2]
lam_values = [1, 1, 1, 2]
linestyles = ['-', '--', ':', '-.', '--']
mu = 0
x = np.linspace(-10, 10, 1000)
fig, ax = plt.subplots(figsize=(5, 3.75))
for (k, lam, ls) in zip(k_values, lam_values, linestyles):
dist = dweibull(k, mu, lam)
plt.plot(x, dist.pdf(x), ls=ls, c='black',
label=r'$k=%.1f,\ \lambda=%i$' % (k, lam))
plt.xlim(0, 5)
plt.ylim(0, 0.6)
plt.xlabel('$x$')
plt.ylabel(r'$p(x|k,\lambda)$')
plt.title('Weibull Distribution')
plt.legend()
plt.show()
我发现以下错误:
RuntimeError: LaTeX was not able to process the following string:
b'lp'
Here is the full report generated by LaTeX:
<matplotlib.figure.Figure at 0x22c11c7a2e8>
我不知道“b'lp”在哪里。