Ejemplo n.º 1
0
def Arrhenius_outline(xlow=6., xhigh=11., ybottom=-18., ytop=-8.,
                      celsius_labels = np.arange(0, 2000, 100),
                      shrink_axes_to_fit_legend_by = 0.3, make_legend=False,
                      lower_legend_by=-2., ncol=2):
    """
    Make Arrhenius diagram outline. 
    
    Returns figure, axis, legend handle.
    
    low, high, top, and bottom set the x and y axis limits. 

    celsius_labels sets where to make the temperature tick marks.
    
    If you have issues with the legend position or overlap with main diagram,
    play with the numbers for shrink_legend_by and lower_legend_by
    
    ncol sets the number of columns in the legend.
    """
    fig = plt.figure()
    ax = SubplotHost(fig, 1,1,1)
    ax_celsius = ax.twin()
    parasite_tick_locations = 1e4/(celsius_labels + 273.15)
    ax_celsius.set_xticks(parasite_tick_locations)
    ax_celsius.set_xticklabels(celsius_labels)
    fig.add_subplot(ax)
    ax.axis["bottom"].set_label("10$^4$/Temperature (K$^{-1}$)")
    ax.axis["left"].set_label("log$_{10}$diffusivity (m$^{2}$/s)")
    ax_celsius.axis["top"].set_label("Temperature ($\degree$C)")
    ax_celsius.axis["top"].label.set_visible(True)
    ax_celsius.axis["right"].major_ticklabels.set_visible(False)
    ax.set_xlim(xlow, xhigh)
    ax.set_ylim(ybottom, ytop)
    ax.grid()
    
    # main legend below
    if make_legend is True:
        legend_handles_main = []
        box = ax.get_position()
        ax.set_position([box.x0, box.y0 + box.height*shrink_axes_to_fit_legend_by, 
                         box.width, box.height*(1.0-shrink_axes_to_fit_legend_by)])
        main_legend = plt.legend(handles=legend_handles_main, numpoints=1, 
                                 ncol=ncol, 
                                 bbox_to_anchor=(xlow, ybottom, xhigh-xlow, 
                                                 lower_legend_by),
                                 bbox_transform=ax.transData, mode='expand')
        plt.gca().add_artist(main_legend)
    else:
        legend_handles_main = None
    return fig, ax, legend_handles_main
Ejemplo n.º 2
0
def Arrhenius_outline(low=6.,
                      high=11.,
                      bottom=-18.,
                      top=-8.,
                      celsius_labels=np.arange(0, 2000, 100),
                      figsize_inches=(6, 4),
                      shrinker_for_legend=0.3,
                      generic_legend=True,
                      sunk=-2.,
                      ncol=2):
    """Make Arrhenius diagram outline. Returns figure, axis, legend handle"""
    fig = plt.figure(figsize=figsize_inches)
    ax = SubplotHost(fig, 1, 1, 1)
    ax_celsius = ax.twin()
    parasite_tick_locations = 1e4 / (celsius_labels + 273.15)
    ax_celsius.set_xticks(parasite_tick_locations)
    ax_celsius.set_xticklabels(celsius_labels)
    fig.add_subplot(ax)
    ax.axis["bottom"].set_label("10$^4$/Temperature (K$^{-1}$)")
    ax.axis["left"].set_label("log$_{10}$diffusivity (m$^{2}$/s)")
    ax_celsius.axis["top"].set_label("Temperature ($\degree$C)")
    ax_celsius.axis["top"].label.set_visible(True)
    ax_celsius.axis["right"].major_ticklabels.set_visible(False)
    ax.set_xlim(low, high)
    ax.set_ylim(bottom, top)
    ax.grid()

    # main legend below
    legend_handles_main = []
    box = ax.get_position()
    ax.set_position([
        box.x0, box.y0 + box.height * shrinker_for_legend, box.width,
        box.height * (1.0 - shrinker_for_legend)
    ])
    main_legend = plt.legend(handles=legend_handles_main,
                             numpoints=1,
                             ncol=ncol,
                             bbox_to_anchor=(low, bottom, high - low, sunk),
                             bbox_transform=ax.transData,
                             mode='expand')
    plt.gca().add_artist(main_legend)
    return fig, ax, legend_handles_main