matplotlib 调整spines

作者: 球果假水晶蓝 | 来源:发表于2023-02-01 00:36 被阅读0次
import numpy as np
import matplotlib.pyplot as plt

# Fixing random state for reproducibility
np.random.seed(19680801)

fig, ax = plt.subplots()

image = np.random.uniform(size=(10, 10))
ax.imshow(image, cmap=plt.cm.gray)
ax.set_title('dropped spines')

# Move left and bottom spines outward by 10 points
ax.spines['left'].set_position(('outward', 10)) # left 线往左移动10
ax.spines['bottom'].set_position(('outward', 10))   # bottom 线往左移动10
# Hide the right and top spines
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
# Only show ticks on the left and bottom spines
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')

plt.show()
i.png

相关文章

网友评论

    本文标题:matplotlib 调整spines

    本文链接:https://www.haomeiwen.com/subject/zqzbhdtx.html