とpythonでYLimプロパティを設定:私はplt.ylim(10**39, 10**41)
一部をコメントアウトする場合は、私は次のコードで簡単なグラフをプロットしようとしていますmatplotlibの
import numpy as np
import matplotlib.pyplot as plt
import math
# evenly sampled time at 200ms intervals
t = np.arange(0., 60, .8)
plt.semilogy((((1- np.exp(-t**2/13.94))*(0.000567*(7.78*(1-np.exp(-33**2/t**2))*np.exp(-t/8.76)+1.50*(1-np.exp(-31**2/t**2))*(np.exp(-t/111.27)-np.exp(-t/8.76)))*10**43))+((1-np.exp(-t**2/13.94))*0.000567*0.05*(np.exp(-t/111.27)-np.exp(-t/8.76))*10**43)), linewidth=2)
#plt.legend([r"$t_{r} \approx (11 - 1)\sqrt{(M_{c}/M_{ch})}d$", r"$t_{r} \approx (11+1)\sqrt{(M_{c}/M_{ch})}d$"], loc='upper right')
plt.ylim(10**39, 10**41)
plt.xlabel("Time (Days)", fontsize =13)
plt.ylabel("Luminosity (erg/s)", fontsize=13)
plt.show()
コードだけで正常に動作します。しかし、イルミムを設定することなく、私は私が望んでいないプロットに多くの空白を持っています。私が受け取っているエラーは次のとおりです。
bolo.py:14: RuntimeWarning: divide by zero encountered in divide
plt.semilogy((((1- np.exp(-t**2/13.94))*(0.000567*(7.78*(1-np.exp(-33**2/t**2))*np.exp(-t/8.76)+1.50*(1-np.exp(-31**2/t**2))*(np.exp(-t/111.27)-np.exp(-t/8.76)))*10**43))+((1-np.exp(-t**2/13.94))*0.000567*0.05*(np.exp(-t/111.27)-np.exp(-t/8.76))*10**43)), linewidth=2)
Traceback (most recent call last):
File "bolo.py", line 17, in <module>
plt.ylim(10**39, 10**41)
File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py", line 1604, in ylim
ret = ax.set_ylim(*args, **kwargs)
File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 3047, in set_ylim
bottom, top = mtransforms.nonsingular(bottom, top, increasing=False)
File "/home/trina/anaconda2/lib/python2.7/site-packages/matplotlib/transforms.py", line 2751, in nonsingular
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
これを解決する方法はありません。あなたの提案は高く評価されます。 私は今イルミムなしで持っているプロットを添付しています。
http://stackoverflow.com/questions/15858192/how-to-set-xlim-and-ylim-for-a-subplot-in-matplotlib – Ezio