import numpy as np import pandas as pd import matplotlib.pyplot as plt

x = np.arange(0, 90, 10) y1 = np.random.randint(130, 160, 90) y2 = np.random.randint(80000, 88000, 90)

plt.rcParams['font.sans-serif'] = ['KaiTi'] plt.rcParams['axes.unicode_minus'] = False fig = plt.figure(figsize=(8, 6)) plt.xlim(0, 90) plt.ylim(0, 90000) plt.xticks(np.arange(0, 100, 10), ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90"]) plt.yticks(np.arange(0, 100000, 10000), ["0", "1万", "2万", "3万", "4万", "5万", "6万", "7万", "8万", "9万"]) plt.xlabel("Variation", labelpad=10, fontsize='xx-large', color='#70AD47', fontweight='bold') plt.ylabel("Capacity", labelpad=10, fontsize='xx-large', color='#70AD47', fontweight='bold') plt.grid(b=True, linestyle="dashed", linewidth=1) plt.title(label="SKU1 Variation与Capacity变化关系", loc="center")

for a, b in zip(x, y1): plt.text(a, b, str(b), ha='center', va='bottom', fontsize=11)

for a, b in zip(x, y2): plt.text(a, b, str(b), ha='center', va='bottom', fontsize=11)

plt.plot(np.arange(0, 90, 10), np.repeat(y1, 10), color="k", linestyle="solid", linewidth=1, marker="o", markersize=3, label='折线图')

width = 3 plt.bar(x - width / 2, y2, width=width, color="k", label='柱形图')

plt.legend(loc="upper left") plt.legend(ncol=2)

plt.annotate("服务器宕机了", xy=(60, 1), xytext=(70, 1), arrowprops=dict(facecolor='black', arrowstyle='->'))

plt.savefig("sku1.png") plt.show()

用python完成以下需求请示例代码:import numpy as np import pandas as pd import matplotlibpyplot as plt x = nparange0 90 10 y1 = 0 180 160 140 150 130 140 140 130 130 140 140 150 130 140 130 130

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

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