mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-10 12:42:34 +00:00
feat(editor): ChatExcel
🔥ChatExcel Mode Operation Manual
This commit is contained in:
parent
4cada93bfa
commit
1fbf5ea5ba
@ -10,6 +10,7 @@ import seaborn as sns
|
||||
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.ticker as mtick
|
||||
from matplotlib.font_manager import FontManager
|
||||
|
||||
from pilot.configs.model_config import LOGDIR
|
||||
@ -117,6 +118,8 @@ def response_line_chart(speak: str, df: DataFrame) -> str:
|
||||
else:
|
||||
sns.lineplot(data=df, x=x, y=y, ax=ax, palette="Set2")
|
||||
|
||||
ax.yaxis.set_major_formatter(mtick.FuncFormatter(lambda x, _: '{:,.0f}'.format(y)))
|
||||
|
||||
chart_name = "line_" + str(uuid.uuid1()) + ".png"
|
||||
chart_path = static_message_img_path + "/" + chart_name
|
||||
plt.savefig(chart_path, bbox_inches='tight', dpi=100)
|
||||
@ -181,6 +184,8 @@ def response_bar_chart(speak: str, df: DataFrame) -> str:
|
||||
else:
|
||||
sns.barplot(data=df, x=x, y=y, hue=hue, palette="Set2", ax=ax)
|
||||
|
||||
# 设置 y 轴刻度格式为普通数字格式
|
||||
ax.yaxis.set_major_formatter(mtick.FuncFormatter(lambda x, _: '{:,.0f}'.format(y)))
|
||||
|
||||
chart_name = "bar_" + str(uuid.uuid1()) + ".png"
|
||||
chart_path = static_message_img_path + "/" + chart_name
|
||||
@ -214,8 +219,6 @@ def response_pie_chart(speak: str, df: DataFrame) -> str:
|
||||
# fig, ax = plt.pie(df[columns[1]], labels=df[columns[0]], autopct='%1.1f%%', startangle=90)
|
||||
fig, ax = plt.subplots(figsize=(8, 5), dpi=100)
|
||||
ax = df.plot(kind='pie', y=columns[1], ax=ax, labels=df[columns[0]].values, startangle=90, autopct='%1.1f%%')
|
||||
# 手动设置 labels 的位置和大小
|
||||
ax.legend(loc='upper right', bbox_to_anchor=(0, 0, 1, 1), labels=df[columns[0]].values, fontsize=10)
|
||||
|
||||
plt.axis('equal') # 使饼图为正圆形
|
||||
# plt.title(columns[0])
|
||||
|
Loading…
Reference in New Issue
Block a user