如何通过HTML将matplotlib饼图传递给Outlook?

2024-09-28 17:16:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将matplotlib饼图转换为outlook(HTML),以便接收它的人也能看到这些图表。你知道吗

迄今为止的准则是:

import sys
import os
import numpy as np
import pandas as pd
from datetime import datetime,date, timedelta
import gc
import calendar
import win32com.client
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import io

labels = 'Updated', 'Outdated', 'Not in Scope'
sizes = [254, 6, 3]
explode = (0.1, 0.2, 0.1)  # only "explode" the 2nd slice (i.e. 'Hogs')
colors = ['Blue', 'Green', 'Red']



fig1, ax1 = plt.subplots(figsize=(5, 5))
total = sum(sizes)

ax1.pie(sizes, explode=explode, labels=labels, 
        shadow=True, startangle=180,labeldistance= 1.2,autopct=lambda p: '{:.0f}'.format(p * total / 100),radius=1.5,rotatelabels = True)
ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.

ax1.set_title("Servers Compliance ")

#patches, texts = ax1.pie(sizes, colors=colors, startangle=180)
ax1.legend(loc="lower left")

plt.show()

我能把这个图(饼图)传递给嵌入HTML的Outlook吗?你知道吗


Tags: importtruedatetimelabelsmatplotlibhtmlasplt