1.代码:
import pandas as pd import matplotlib.pyplot as plt data = { '花菜类': [17076.281, 9777.898, 14935.598], '花叶类': [71595.317, 48109.44, 78954.796], '辣椒类': [26703.357, 21502.322, 43439.433], '茄类': [8950.42, 7973.492, 5518.207], '食用菌': [27312.626, 16265.257, 32553.843], '水生根茎类': [12153.829, 11830.395, 16623.328], } df = pd.DataFrame(data, index=['第一财年', '第二财年', '第三财年']) fig, ax = plt.subplots(figsize=(7, 3), dpi=200) # --- Remove spines and add gridlines #处理中文乱码 plt.rcParams['font.sans-serif'] = ['Microsoft YaHei'] ax.spines["left"].set_visible(False) ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) # --- The data df.plot(ax=ax, marker='o', mfc='white', ms=5) # --- Adjust tickers and spine to match the style of our grid ax.xaxis.set_tick_params(length=2, color="#4E616C", labelcolor="#4E616C", labelsize=6) ax.yaxis.set_tick_params(length=2, color="#4E616C", labelcolor="#4E616C", labelsize=6) ax.spines["bottom"].set_edgecolor("#4E616C") plt.show()
2.效果: