import matplotlib.pyplot as plt

客户规模

customer_sizes = [300, 350, 400, 450, 500, 550, 600]

分区数量

partitions = [6, 7, 8]

平均配送成本

average_costs = [[34.2893, 33.3376,32.9729,32.7279,32.7143,32.6044,32.4504], [34.2878,33.7388,33.3372,32.9542,32.7115,32.3371,32.1999], [34.7602,33.6432,33.2217,33.1579,33.1209,32.8848,32.6923]]

设置字体为Times New Roman

plt.rcParams["font.family"] = "Times New Roman"

绘制折线图

colors = ['red', 'green', 'blue'] for i in range(len(partitions)): plt.plot(customer_sizes, average_costs[i], label="P=" + str(partitions[i]), linestyle='-', marker='o', color=colors[i])

设置图例

plt.legend()

设置标题和坐标轴标签

plt.title("Average delivery cost") plt.xlabel("Customer scale") plt.ylabel("Average delivery cost")

设置斜体

leg = plt.legend() for text in leg.get_texts(): text.set_fontstyle('italic')

显示图形

plt.show(


原文地址: https://www.cveoy.top/t/topic/iokb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录