简体   繁体   中英

Insert pandas chart into an Excel file using XlsxWriter

I use python 3.4, pandas 0.14.1 and XlsxWriter 0.5.6. I create a graph called 'graph' using pandas with the following code

 graph=data_iter['_DiffPrice'].hist() 

, which produces a beautiful histogram.

Now, how do I insert that graph into an Excel file using XlsxWriter?

I tried the XlsxWriter method

workbook.add_chart()

but this creates a graph in Excel, not what I want.

Thanks

If you would like to export Pandas data as charts in Excel using XlsxWriter then have a look at the following how-to (that I wrote): Using Pandas and XlsxWriter to create Excel charts .

在此输入图像描述

If on the other hand you want the matplotlib style charts generated by Pandas then export them as images and insert them into a worksheet using the XlsxWriter insert_image() method.

See also Working with Python Pandas and XlsxWriter .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM