2017-05-30 51 views
-2

我的身材在我的身材內的框架是不可見的。我試過ax.spines.set_visible(True),ax.axis(「on」)等,但似乎沒有任何工作。下面你可以找到我想要繪製的具體情節的代碼以及我在開始時使用的設置。任何人都知道如何使軸周圍的框架可見?我檢查了已經在stackoverflow的解決方案,但他們也沒有爲我工作。謝謝。Matplotlib框架隱形

import matplotlib as mpl 
    mpl.use('Agg') 
    import matplotlib.pyplot as plt 
    from mpl_toolkits.mplot3d import Axes3D 
    plt.style.use(['seaborn-white','seaborn-paper']) 
    import seaborn as sns 
    sns.set(font='serif') 

    fig = plt.figure() 
    ax1 = fig.add_subplot(211) 
    ax2 = fig.add_subplot(212, sharex=ax1) 

    ax1.set_facecolor("white") 
    ax1.axhline(19, color='r', label='$T_{lim}$') 
    ax1.axhline(23, color='r') 
    ax1.plot(Tair, color='b', linewidth=1, label='$T_{air}$') 
    ax1.plot(Tout, color='m', linewidth=1, label='$T_{out}$') 
    ax1.set_ylabel('T [°C]', fontsize=15) 
    ax1.legend(loc='center left', bbox_to_anchor=(1, 0.5)) 
    ax1.set_xlim([0, 1440 * (day + 1)]) 
    ax1.set_xlabel('Time [quarters]', fontsize=15) 

    ax2.set_facecolor("white") 
    ax2.plot(u_phys, color='b', linewidth=1, label='$u$') 
    ax3 = ax2.twinx() 
    ax3.plot(price, color='g', linewidth=1, label='$p$') 
    ax3.grid(b=False) 
    ax3.set_ylabel('Price [€c/kWh]', fontsize=15, color='g') 
    ax3.tick_params('y', colors='g') 
    ax2.set_xlabel('Time [quarters]', fontsize=15) 
    ax2.set_ylabel('Power [kW]', fontsize=15, color='b') 
    ax2.tick_params('y', colors='b') 
    ax2.set_xlim([0, 1440 * (day + 1)]) 
    ax2.set_ylim(0, 3.2) 
    ax2.set_xticks(np.arange(1440 * (day + 1))[::1440]) 
    ax2.set_xticklabels(np.arange(day + 1)) 
    ax2.set_yticks(np.arange(self.n_actions + 1)) 
    ax2.set_yticklabels(np.array([0, 1, 2, 3, 4])) 
    ax2.xaxis.set_visible(True) 
    ax1.xaxis.set_visible(True) 
    fig.subplots_adjust(left=0.09, wspace=0, hspace=0.26, right=0.88, bottom=0.09, top=0.97) 

回答

1

你在這裏混合了很多風格。最好決定是使用seaborn風格還是matplotlib風格,只使用其中一個來定義風格。 因爲看起來你實際上並不需要海豹,所以你可以將它完全拋棄。

import numpy as np 
import matplotlib as mpl 
mpl.use('Agg') 
import matplotlib.pyplot as plt 

plt.style.use(['seaborn-white','seaborn-paper']) 
plt.rcParams["font.family"] = "serif" 

enter image description here

+0

那沒有工作!感謝您的快速回復! – cpat