How to generate a report having a pie chart in python? - python

I'm using ReportLab for generating reports in PDF. I'm able to get a pdf havinf only textual content in it, but I want to represent the information in the form of a pie chart.
Here is the information that I want to represent on the pie chart.
[[New Delhi,110kWh],[Bangalore,200kWh]
ie a pir should have regions of New Delhi and Bangalore with their respective values in percentage.
How can I bring a pie chart into the PDF for generation of reports.

You can use matplotlib to generate a pie chart. See the example here.
Save the chart as a image file and place it in your PDF.

you can use this tutorial for creating pie-chart using ReportLab : http://www.reportlab.com/snippets/2/
For other types of scientific or data visualizations matplotlib is also good.

Related

copy created pie chart and calculated values to csv file

I almost completed my project but need some help. Let me summarize what I have already done. I exported a CSV file from ESXI, and using Python, I make several calculations and created a pie chart of these values. Here I have one result for calculation and the pie chart. Currently, I want to write these results to CSV simultaneously. How can I do that? As you know, pandas only display pie charts on different windows. I want to save that chart on CSV.
A pie chart is just a type of data visualization. I guess you are already using a dataframe to display this using plt.show().if you want to save that chart,
you could combine data,labels,colors to dataframe and save it as a csv. In order to save as csv: df.to_csv(file_name, sep='\t')

annotation while hovering over saved matplotlib plots

The amount of data that I need to plot is above 30k points. I'm aware that the hover over functionality is possible for an active graph. But is it possible to display the value of a particular data point when hovered over on saved matplotlib plots?
Are there any other interactive plotters that offer such a functionality for saved plots?

Add a databox to a plotly subplot

I am trying to build a tearsheet where there will be charts on the left and data on the right. This is being exported from within a python financial application.
The plots are no problem but I cannot find online how to add the text box on the right side of the sub-plot.
Is there a way to add data in a chart box such as in the example linked above?

Image background in bar charts using bokeh (python)

I have a basic bar chart with the x-axis having categorical values of countries. I want to give each bar, an image background of the country's flag, to make the chart more appealing also to eliminate the x-axis labels. I am currently using bokeh for my charts and I dont think it is possible via this. Any ideas for the same, maybe some other python libraries which might do the trick?
Thanks

How to save Python plots with entire information like in interactive Plots (output of plt.show())?

When I use Matplotlib's plt.show() I get a nice Plot which can can be zoomed to very high precision(practically infinite). But when I save it as a image it loses all this information gives information depending on resolution.
Is there any way I can save the plot with the entire information? i.e Like those interactive plots which can rescaled at any time?
P.S- I know I can set dpi to get high quality images. This is not what I want. I want image similar to Plot which python shows when I run the program. What format is that? Or is it just very high resolution image?
Note- I am plotting .csv files which includes data varying from 10^(-10) to 100's. Thus when I save the plot as .png file I lose all the information/kinks of graph at verŠ½ small scales and only retain features from 1-100.
Maybe the interactive graphic library bokeh is an option for you. See here. It's API is just little different from what you know from matplotlib.
Bokeh creates plots as html files that you can view in your browser. For each graphic you can select wheel zoom to zoom interactively into your graphic. You can change interactively the range that you want to be plotted. Therefore you don't loose information in your graphic.

Categories

Resources