Generating Reports with Python: PDF or HTML to PDF - python

Using maptplotlib I have created 9 graphs which are combined in to a single pdf using the command savefig. However I need to be able to show the statistical analysis below each plot with .describe(). What would be the best way to do this?

Pandas has the possibility to include a table with a plot. See the table kwarg to pandas.DataFrame.plot. See the docs: http://pandas.pydata.org/pandas-docs/dev/visualization.html#visualization-table

There are multiple possibilities:
http://pbpython.com/pdf-reports.html
http://gael-varoquaux.info/computers/pyreport/
https://github.com/JanSchulz/knitpy
For the last, have a look at https://github.com/JanSchulz/knitpy/tree/master/examples, the docx, pdf and html versions were generated from the .pymd source. The example includes both pandas.DataFrames and matplotlib figures.
Disclaimer: I'm the author of knitpy

Related

Exporting functional Plotly sunburst plot

Does anyone know how I can export a plotly sunburst plot as a standalone file which can keep all the functionalities, like annotation while hovering and expansion by click?
Visualizing a hierarchical data with plotly.sunburst in python is a beautiful and beneficial way of presenting it in the best order, while you are able to hover the values to see the annotation, click on each parent section to collapse and expand the child values, etc.. But to present the visualized data (plot) independently without having to open the Python notebook, needs the plot to be saved and exported in a standalone file format that allows keeping every functionality available.
Does anyone know how to do this? and what file format can give this luxury to us?
Thanks
Saving to an HTML file will do the trick:
doc

Is there any way to save all graphs generated using the script to a single file (image preferably)

The scripts I use generate a lot of graphs. I was wondering if there was a way to save them or specified ones into a single file as image or pdf for quicklooks.
Thank you.
If you are using matplotlib, it would be easiest to use the subplots feature. This will make all of your graphs part of a single object, which can be saved as an image like you want. I would redirect you to the matplotlib website for a ton of good example on the subject. https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.subplots.html
Then, do
fig.savefig('mysweetsubplots.png')
and you are done.

combined different objects contains plots and data frames (tables) and paragraphs (markdowns) in to single html report

I want to generate a single report that integrates different objects as my analysis inlcudes plots (matplotlib, seaborn and bokeh) and pandas data frames (tables) and paragraphs (markdowns) into an HTML report in python
Use Jupyter or Zeppelin notebooks. They provide all of the functionality you described and can export to PDF. Reports can even be run/emailed on a predetermined schedule.

A text only PDF page using matplotlib

I am generating a multi-page PDF with different graphs in each page using matplotlib. I would like to add another page that contains some information relevant to these graphs. But all text addition methods I've seen in matplotlib so far, seem to require a figure to be present already. Is it possible to add a text only page in matplotlib?

Writing a table to a matplotlib pdf file

I am using matplotlib and a modified version of this example to generate plots in pdf files. So I am plotting each plot on a single page and the results are just fine.
Now I would like to list all the data used in the plots in a rather long table. This table should be placed below the last plot (so not each plot should get its own table).
Is there a way to plot LaTeX like tables in a pdf file using matplotlib?
In principle, you can place almost any TeX stuff onto a plot using something like plt.text(1,2,r'$a^2+b^2=42$'). For aligning equations things like eqnarray work as well, like this. Just don't forget to use raw strings, for otherwise python can misinterpret TeX commands which start with backslashes.
Unless using a plot to write text, I think it is save to say, that it is not possible to only write a table to a matplotlib pdf output file.
Currently I am using tex to write the table and pyPdf to merge the two results. I think this is the cleanest solution to the problem.

Categories