def line():
"""
Creates a single graph with date and time as the x axis and
a variable number of plots.
"""
# Save data to redraw plot later
save_data('line')
# set the screen title, size, density
fig = plt.figure(title,graph_dimensions,graph_dpi)
# do the plot
plt.title(title)
plt.ylabel(ylabel1)
plt.grid(which="major")
for plot_num in range(len(ylists)):
plt.plot(xdatetimes,ylists[plot_num],color=my_colors(plot_num))
# date time formatting
ax = plt.axes()
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)
# other formatting
plt.legend(ylistlabels,loc='upper left')
plt.autoscale(tight=True)
# subplots_adjust settings - single plot so zero space between plots
vleft = 0.06 # the left side of the subplots of the figure
vright = 0.97 # the right side of the subplots of the figure
vbottom = 0.12 # 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.0 # 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
评论列表
文章目录