myplot.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:PythonDBAGraphs 作者: bobbydurrett 项目源码 文件源码
def line_2subplots():
    """
    Creates a split plot with one set of x axis labels and
    two subplots.

    """

# Save data to redraw plot later

    save_data('line_2subplots')

# set the screen title, size, density

    fig = plt.figure(title,graph_dimensions,graph_dpi)

# do the plot
# top half of the graph plot_number 1
    nrows = 2
    ncols = 1
    plot_number = 1   
    ax = plt.subplot(nrows,ncols,plot_number)
    plt.title(title)
    plt.ylabel(ylabel1)
    plt.grid(which="major")
    red = 'r'
    plt.plot(xdatetimes,ylists[0],red)
    plt.autoscale(tight=True)
    fig.autofmt_xdate()
    ax.fmt_xdata = mdates.DateFormatter('%m/%d/%Y %H:%M')
    datetimefmt = mdates.DateFormatter('')
    ax.xaxis.set_major_formatter(datetimefmt)
# bottom half of the graph plot_number 2
    plot_number = 2   
    ax = plt.subplot(nrows,ncols,plot_number)
    plt.ylabel(ylabel2)
    plt.grid(which="major")
    green='g'
    plt.plot(xdatetimes,ylists[1],green)
    plt.autoscale(tight=True)
    fig.autofmt_xdate()
    ax.fmt_xdata = mdates.DateFormatter('%m/%d/%Y %H:%M')
    loc=mdates.AutoDateLocator()
    datetimefmt = mdates.AutoDateFormatter(loc)
    ax.xaxis.set_major_formatter(datetimefmt)
    ax.xaxis.set_major_locator(loc)

# subplots_adjust settings
    vleft  = 0.07  # the left side of the subplots of the figure
    vright = 0.97    # the right side of the subplots of the figure
#    vbottom = 0.15   # the bottom of the subplots of the figure
    vbottom = 0.10   # the bottom of the subplots of the figure
    vtop = 0.95      # the top of the subplots of the figure
    vwspace = 0.0   # the amount of width reserved for blank space between subplots
    vhspace = 0.08   # the amount of height reserved for white space between subplots

    plt.subplots_adjust(left=vleft,right=vright,bottom=vbottom,top=vtop,wspace=vwspace,hspace=vhspace)


    fileorscreen(title+'.png')

    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号