2017-05-30 16 views
-2

私の体の中の私の軸のフレームは見えません。私はax.spines.set_visible(True)、ax.axis( "on")などを試しましたが、何も動作していないようです。下に、描画しようとしている特定のプロットのコードと、最初に使用した設定があります。誰でも、軸周りのフレームを表示する方法を知っていますか?私はすでにstackoverflow上にあるソリューションをチェックしたが、どちらも私のために働いていなかった。ありがとう。Matplotlib Frame Invisible

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スタイルのどちらかを決定し、スタイルの定義にそれらの1つだけを使用するのが最善です。 ここに実際に海底が必要ないと思われるので、完全に放置することができます。作業を行った

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