python - Errors writing multiple figures to a .pdf -


when generating pdf below dataframes , series, pandas generating 2 blank figures , inserting them .pdf file. figure 1 , figure 3 both blank while figure 2 , figure 4 printing .pdf file. had hoped write 3 figures below (fig1, fig2, , fig3) .pdf file.

import matplotlib.pyplot plt matplotlib.backends.backend_pdf import pdfpages pandas.tools.plotting import bootstrap_plot pandas.tools.plotting import scatter_matrix pandas import *  range_days = 10 ydate = "2014-09-09" wdate = "2014-08-31"  c_data = [1,2,3,4,3,2,1,3,4,5] p_data = [1,2,3,4,3,2,1,3,4,5] d_data = [1,2,3,4,3,2,1,3,4,5]  d = {"c":series(c_data, index=date_range(wdate, periods=range_days)),"p": series(p_data, index=date_range(wdate, periods=range_days)),"d":series(d_data, index=date_range(wdate, periods=range_days))} d2 = {"c":d["c"], "p":d["p"]}  ts2 = dataframe(d2, index=date_range(wdate, periods=range_days)) ts = dataframe(d, index=date_range(wdate, periods=range_days))  pdf_name = "metrics_" + str(wdate) + "_to_" + str(ydate)+ ".pdf" pdf = pdfpages(pdf_name)  #p & c on time fig1 = plt.figure() ts2.plot(secondary_y=["p"]) pdf.savefig(fig1)  #density plot of c fig2 = plt.figure() d["c"].plot(kind="kde") pdf.savefig(fig2)  #scatter matrix on data_frame fig3 = plt.figure() scatter_matrix(ts, alpha=0.2, figsize=(6, 6), diagonal='kde') pdf.savefig(fig3)  pdf.close() 

removal of of plt.figure() variables removes blank figures being created , insertion pdf file.

import matplotlib.pyplot plt matplotlib.backends.backend_pdf import pdfpages pandas.tools.plotting import bootstrap_plot pandas.tools.plotting import scatter_matrix pandas import *  range_days = 10 ydate = "2014-09-09" wdate = "2014-08-31"  c_data = [1,3,3,2,3,2,1,6,7,9] p_data = [0,5,6,11,3,2,1,1,3,4] d_data = [1,7,3,8,3,2,1,3,2,3]  d = {"c":series(c_data, index=date_range(wdate, periods=range_days)),"p": series(p_data, index=date_range(wdate, periods=range_days)),"d":series(d_data, index=date_range(wdate, periods=range_days))} d2 = {"c":d["c"], "p":d["p"]}  ts2 = dataframe(d2, index=date_range(wdate, periods=range_days)) ts = dataframe(d, index=date_range(wdate, periods=range_days))  pdf_name = "metrics_" + str(wdate) + "_to_" + str(ydate)+ ".pdf" pdf = pdfpages(pdf_name)  #p & c on time ts2.plot(secondary_y=["p"]) pdf.savefig()  #density plot of conversion plt.figure() d["c"].plot(kind="kde") pdf.savefig()  #scatter matrix on data_frame scatter_matrix(ts, alpha=0.2, figsize=(6, 6), diagonal='kde') pdf.savefig()  pdf.close() 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -