0

我有一个基于 multiple_yaxis_with_spines.py 的 python 例程(在 matplotlib 页面http://matplotlib.org/中提供的示例)在将 matplotlib 升级到 1.1.1 之后无法正常工作(即使是原始版本也有问题)。第三个斧头(红色)不再出现​​,对应的数据绘制在蓝色斧头(左)之后[见下面的图像和代码]。我目前在 Windows 7 中使用 python 2.7.3 32bits,matplotlib 1.1.1 > 我的问题是:matplotlib 库中有哪些变化影响了这个功能?如何解决这个问题并允许我毫无问题地升级 python 和库? http://tinypic.com/r/33pfz13/5 - 数据应该如何显示

    def make_patch_spines_invisible(ax):
        par2.set_frame_on(True)
        par2.patch.set_visible(False)
        for sp in par2.spines.itervalues():
            sp.set_visible(False)

    def make_spine_invisible(ax, direction):
        if direction in ["right", "left"]:
            ax.yaxis.set_ticks_position(direction)
            ax.yaxis.set_label_position(direction)
        elif direction in ["top", "bottom"]:
            ax.xaxis.set_ticks_position(direction)
            ax.xaxis.set_label_position(direction)
        else:
            raise ValueError("Unknown Direction : %s" % (direction,))
        ax.spines[direction].set_visible(True)

    if 1:
        fig = plt.figure()
        host = fig.add_subplot(111)
        par1 = host.twinx() 
        par2 = host.twinx() 
        par2.spines["right"].set_position(("axes", 1.1))
        make_patch_spines_invisible(par2)
        make_spine_invisible(par2, "right")
        plt.subplots_adjust(right=0.8) 
        p1, = host.plot(t,hmf2i,'b-',label="hmf2")
        p2, = par1.plot(t,fof2i,"r-",label="foF2")
        p3, = par2.plot(t,hvirfi,'g-',label="h\'F")
        host.set_xlim(0,24) 
        #host.set_ylim(250,600)
        #par1.set_ylim(9,18)
        #par2.set_ylim(200,450)
        host.set_xlabel("Hora (UT)")
        #host.set_ylabel("hmF2 (km)")
        #par1.set_ylabel("foF2 (MHz)")
        #par2.set_ylabel("h\'F (km)") 
        host.yaxis.label.set_color(p1.get_color())
        par1.yaxis.label.set_color(p2.get_color())
        par2.yaxis.label.set_color(p3.get_color()) 
        tkw = dict(size=4, width=1.5)
        host.tick_params(axis='y',colors=p1.get_color(),**tkw)
        par1.tick_params(axis='y',colors=p2.get_color(),**tkw)
        par2.tick_params(axis='y',colors=p3.get_color(),**tkw) 
        host.tick_params(axis='x',**tkw)
        lines = [p1, p2, p3] #(comentar se não houver terceiro plot)
        host.legend(lines,[l.get_label() for l in lines],loc = 'upper center') 
        plt.xlim(0,24)
        plt.xticks(np.linspace(0, 24, 7, endpoint=True))
        plt.title('hmF2, foF2 e h\'F para ' + fn[:-4])
        plt.grid(True)
        plt.savefig(directory+'out\\'+fn[:2]+fn[-9:-4]+'_h_fo')
        plt.clf() 
        plt.gcf() 
        plt.close() 

在此处输入图像描述

4

0 回答 0