2017-05-30 46 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