如何使matplotlib图(图2)与海运图(图1)相同?我要移除中央电网。
我尝试使用plt.gca().axes.xaxis.set_ticklabels([]),但它也删除了标签。

发布于 2021-08-04 06:49:45
如果绘图中已经存在网格,如图2所示,则可以关闭将b = False和axis = 'x'传递到plt.grid()的水平网格线。
ax.grid(b = False, axis = 'x')示例:
import matplotlib.pyplot as plt
x = ['a', 'b', 'c', 'd', 'e']
y = [10, 15, 11, 12, 8]
plt.style.use('seaborn-whitegrid')
fig, ax = plt.subplots()
ax.bar(x = x, height = y, color = 'blue')
ax.grid(b = False, axis = 'x')
plt.show()

https://stackoverflow.com/questions/68643871
复制相似问题