如何使用boxstyle作为pad,使用round作为矩形?

2024-03-28 11:44:47 发布

您现在位置:Python中文网/ 问答频道 /正文

您好,我使用Python和模块Matplotlib编写了以下代码:

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

f = plt.figure()

gs0 = gridspec.GridSpec(1, 1, figure=f)
gs00 = gridspec.GridSpecFromSubplotSpec(3, 3, subplot_spec=gs0[0])

ax1 = f.add_subplot(gs00[:, :-1])
ax2 = f.add_subplot(gs00[:-1, -1])
ax3 = f.add_subplot(gs00[-1, -1])

ax1.axis('off')
ax2.axis('off')
ax3.axis('off')

ax1.text(0.5, 0.5, "ax1", va="center", ha="center")
ax2.text(0.5, 0.5, "ax2", va="center", ha="center")
ax3.text(0.5, 0.5, "ax3", va="center", ha="center")

f.add_artist(plt.Rectangle((0.01, 0.01), 0.99, 0.99,
                  edgecolor = 'black', facecolor = 'orange',
                  fill = False, angle=40,
                  linewidth = 3, zorder = 1))
plt.show()

但是我想在我的矩形中使用类似的东西boxstyle='round,pad=1'

因为我有:

Original

我想要这个:

What I would like to have

非常感谢你的帮助


Tags: textimportaddpltcenteroffhaaxis