2016-08-20 4 views
1

私の 'y'軸のすべてをサブプロットに移動した後、不要な軸が得られます。左の黒い部分です。誰もそれを取り除く方法を知っていますか?私は数字を呼ぶときそれがプロットされていると確信していますが、私はそれを取り除く方法がわかりません。誰かがMatplotlibプロットの黒い「y」軸を左に取り除く方法を知っていますか?

enter image description here

def mpl_plot(self, plot_page, replot = 0): #Data stored in lists 


    if plot_page == 1:    #Plot 1st Page       
     #plt0 = self.mplwidget.axes         
     fig = self.mplwidget.figure #Add a figure    


    if plot_page == 2:   #Plot 2nd Page 
     #plt0 = self.mplwidget_2.axes 
     fig = self.mplwidget_2.figure #Add a figure 


    if plot_page == 3:   #Plot 3rd Page 
     #plt0 = self.mplwidget_3.axes 
     fig = self.mplwidget_3.figure #Add a figure 

    #Clears Figure if data is roplotted 

    if replot == 1: 
     fig.clf() 

    par0 = fig.add_subplot(111) 
    par1 = fig.add_subplot(111) 
    par2 = fig.add_subplot(111) 

    #Add Axes 
    plt = par0.twinx() 
    ax1 = par1.twinx()   
    ax2 = par2.twinx() 

    impeller = str(self.comboBox_impellers.currentText()) #Get Impeller 
    fac_curves = self.mpl_factory_specs(impeller)  
    fac_lift = fac_curves[0]   
    fac_power = fac_curves[1] 
    fac_flow = fac_curves[2] 
    fac_eff = fac_curves[3]   
    fac_max_eff = fac_curves[4] 
    fac_max_eff_bpd = fac_curves[5] 
    fac_ranges = self.mpl_factory_ranges() 
    min_range = fac_ranges[0] 
    max_range = fac_ranges[1] 

    #Plot Chart 
    plt.hold(True)  
    plt.plot(fac_flow, fac_lift, 'b', linestyle = "dashed", linewidth = 1)   

    ax1.plot(fac_flow, fac_power, 'r', linestyle = "dashed", linewidth = 1) 

    ax2.plot(fac_flow, fac_eff, 'g', linestyle = "dashed", linewidth = 1) 

    #Move spines  

    ax2.spines["right"].set_position(("outward", 25)) 
    self.make_patch_spines_invisible(ax2) 
    ax2.spines["right"].set_visible(True) 
    #Plot x axis minor tick marks 
    minorLocatorx = AutoMinorLocator()   
    ax1.xaxis.set_minor_locator(minorLocatorx) 
    ax1.tick_params(which='both', width= 0.5) 
    ax1.tick_params(which='major', length=7) 
    ax1.tick_params(which='minor', length=4, color='k') 

    #Plot y axis minor tick marks 
    minorLocatory = AutoMinorLocator() 
    plt.yaxis.set_minor_locator(minorLocatory) 
    plt.tick_params(which='both', width= 0.5) 
    plt.tick_params(which='major', length=7) 
    plt.tick_params(which='minor', length=4, color='k') 

    #Make Border of Chart White 
    fig.set_facecolor('white')   
    #Plot Grid   

    plt.grid(b=True, which='both', color='k', linestyle='-') 

    #set shaded Area 
    plt.axvspan(min_range, max_range, facecolor='#9BE2FA', alpha=0.5) #Yellow rectangular shaded area 

    #Set Vertical Lines 
    plt.axvline(fac_max_eff_bpd, color = '#69767A') 

    #BEP MARKER *** Can change marker style if needed 
    bep = fac_max_eff * 0.90  #bep is 90% of maximum efficiency point 

    bep_corrected = bep * 0.90 # We knock off another 10% to place the arrow correctly on chart 

    ax2.annotate('BEP', xy=(fac_max_eff_bpd, bep_corrected), xycoords='data', #Subtract 2.5 shows up correctly on chart 
      xytext=(-50, 30), textcoords='offset points', 
      bbox=dict(boxstyle="round", fc="0.8"), 
      arrowprops=dict(arrowstyle="-|>", 
          shrinkA=0, shrinkB=10, 
          connectionstyle="angle,angleA=0,angleB=90,rad=10"), 
        ) 
    #Set Scales   

    plt.set_ylim(0,max(fac_lift) + (max(fac_lift) * 0.40)) #Pressure 
    #plt.set_xlim(0,max(fac_flow)) 

    ax1.set_ylim(0,max(fac_power) + (max(fac_power) * 0.40))  #Power 
    ax2.set_ylim(0,max(fac_eff) + (max(fac_eff) * 0.40)) #Effiency 

    plt.yaxis.tick_left() 
    # Set Axes Colors 

    plt.tick_params(axis='y', colors='b') 
    ax1.tick_params(axis='y', colors='r') 
    ax2.tick_params(axis='y', colors='g') 

    # Set Chart Labels   
    plt.yaxis.set_label_position("left") 
    plt.set_xlabel("BPD") 
    plt.set_ylabel("Feet" , color = 'b') 

    #ax1.set_ylabel("BHP", color = 'r') 
    #ax1.set_ylabel("Effiency", color = 'g') 

    # Set tight layout  
    fig.set_tight_layout   

    # Since we moved Feet Axis to subplot, extra unneeded axis was created. This Removes it 


    # Refresh 
    fig.canvas.update() 
    fig.canvas.draw() 

答えて

0

さてあなたは3のy軸を持っているように、それはあなたが表示されないようにしたいものを参照し、見える、あなたが追加し試みることができる:ちょうど目に見えないを作るために

ax.yaxis.set_tick_params(labelsize=0, length=0, which='major') 

をラベルとダニ。私はそれがあなたが消えたいax2だと思いますか?

+0

私は実際に4軸を持っています。右側の緑色の部分が明らかに画像から切り刻まれています。謝罪いたします。私が取り除こうとしているのは、左の黒いものです。私はそれを設定していないが、それはちょうどフィギュアと一緒に来た。私はちょうどそれを参照する方法を知らない。 –

関連する問題