示例#1
0
def makeFigure(name='Z dim', path='./', dpi=100):
    fig = plt.figure()
    # fig.suptitle(name)
    ax = HostAxes(fig, [0.08, 0.08, 0.70, 0.8])
    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)
    ax.set_xticks(Z_dim)
    ax.plot(Z_dim, FID, color=cname[0], label='FID')
    ax.set_ylabel('FID')
    ax.set_xlabel('log_2(Z dimension)')
    ax.legend()
    fig.add_axes(ax)

    def paraAxis(x, y, name, cnt):
        ax_para = ParasiteAxes(ax, sharex=ax)
        ax.parasites.append(ax_para)
        ax_para.axis['right'].set_visible(True)
        ax_paraD = ax_para.get_grid_helper().new_fixed_axis
        ax_para.set_ylabel(name)
        ax_para.yaxis.set_label_coords(-1, -0.5)
        ax_para.axis['right'] = ax_paraD(loc='right',
                                         offset=(40 * cnt, 0),
                                         axes=ax_para)
        ax_para.plot(x, y, label=name, color=cname[cnt + 1])
        plt.legend(loc=8, ncol=3)

    paraAxis(Z_dim, IS, "IS", 0)
    paraAxis(Z_dim, nll, "nll", 1)
    plt.savefig(os.path.join(path, 'z_dim.png'), dpi=dpi)
示例#2
0
fig1 = plt.figure(1, figsize=(2.5, 1.2))

host = HostAxes(fig1, [0.15, 0.1, 0.65, 0.8])
par1 = ParasiteAxes(host, sharex=host)
host.parasites.append(par1)

host.axis["right"].set_visible(False)
par1.axis["right"].set_visible(True)

par1.axis["right"].major_ticklabels.set_visible(True)
par1.axis["right"].label.set_visible(True)
fig1.add_axes(host)

host.set_xlim(np.pi / 2, np.pi)
host.set_ylim(0.29, 0.61)
host.set_xticks([1.57, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.1415])
host.set_xticklabels(
    ['$\\pi/2$', '1.8', '2.0', '2.2', '2.4', '2.6', '2.8', '3.0', '$\\pi$'])

host.set_xlabel("$\\theta_c$")
host.set_ylabel("$\\theta_b^*$")
par1.set_ylabel("min$_{\\theta_b} \\varepsilon$ $(\\times 10^{-3})$")

p1, = host.plot(C[0, :],
                X[Z.argmin(axis=0), 0],
                label="$\\theta_b^*$",
                color='#1f77b4')
p2, = par1.plot(C[0, :],
                Z.min(axis=0) * 1000,
                label="min$_{\\theta_b} \\varepsilon$",
                color='#e6550d')