这里写目录标题
绘制稍微复杂函数
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签SimHei
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
x = np.linspace(0.1, 30, 100)
y = np.sqrt(x)-np.log2(x)
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title('f(x)图像')
plt.grid(True)
plt.show()
绘制条形图 一列有两条柱
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
from pylab import mpl
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签SimHei
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
# 设置柱状图的宽度
bar_width = 0.35
# 计算每个柱状图的中心位置
x = np.arange(len(dops))
# 绘图
fig, ax = plt.subplots()
# print(ustore_vals)
# print(astore_vals)
bars1 = ax.bar(x - bar_width / 2, ustore_vals, bar_width, label='Ustore')
bars2 = ax.bar(x + bar_width / 2, astore_vals, bar_width, label='Astore')
# 添加标签、标题和图例
ax.set_xlabel('query_dop')
ax.set_ylabel('Values')
ax.set_title(title)
ax.set_xticks(x)
ax.set_xticklabels(dops)
ax.legend()
# 显示图形
plt.show()
# plt.savefig(path)
# plt.close()
绘制普通折线图
import matplotlib.pyplot as plt
import numpy as np
from pylab import mpl
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签SimHei
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
# 创建折线图
plt.plot(dops, end2end_imp_vals,color='red', linestyle='-', marker='o', label='端到端性能提升')
plt.plot(dops, op_imp_vals,color='blue', linestyle='--', marker='s', label='Seq scan算子性能提升')
# 设置x轴和y轴标签
plt.xlabel('query_dop')
plt.ylabel('性能提升倍数')
plt.legend()
# 设置图表标题
plt.title('Ustore不同并行度下性能提升倍数')
# 显示图表
# plt.show()
plt.savefig(path)
plt.close()