generate matplotlib plot
nplt.figure(figsize=( 8 , 4 ))
nplt.plot(Cell(“A2”).vertical, Cell(“C2”).vertical, label=‘AAPL’)
nplt.legend(loc= 0 )
nplt.grid(True)
nplt.xticks(rotation= 35 )
expose plot to Excel spreadsheet
nplt.graph()
as plt.show()
save the new workbook with data and plot
save(‘dn_plot.xlsx’)
From a DataNitro IPython shell, execute the script with:
In [ 1 ]: %run dn_plotting.py
If the script is successfully executed, the workbook/worksheet in Excel should look as
displayed in Figure 12-6.
Figure 12-6. Screenshot of Excel with DataNitro plot of Apple stock price data
User-defined functions
From a finance point of view, it seems most interesting to expose user-defined functions
(UDFs) via DataNitro to Excel. This option has to be enabled in the Settings menu of
DataNitro. Once this is enabled, you can import a Python script with DataNitro called
functions.py. All Python functions included in this file — and they have to be in this