【发布时间】:2021-12-10 22:56:58
【问题描述】:
我想绘制/绘制一个“括号”(为简单起见,它是形成弧的一系列点),如第一张图片中的红色所示。
我在另一个图中创建了括号,但我不知道如何在第一个图中包含/绘制/绘制它。这是括号,它会根据需要进行转换以适应小标签和标签组之间的空间。
这是 MWE:
import matplotlib.pyplot as plt
import numpy as np
fig, axs = plt.subplots(8, 1, figsize=(8,9), sharex=True)
for i, ax in enumerate(axs.flat):
ax.plot([1,2])
ax.set_ylabel('Label ' + str(i))
axs[7].set_xlabel('The common x Label')
plt.annotate('Group Label (0,1,2,3)', xy=(.02, 0.7), rotation=90, xycoords='figure fraction',
horizontalalignment='center', verticalalignment='center', fontsize=14, color='k')
plt.annotate('Group Label (4,5,6,7)', xy=(.02, 0.3), rotation=90, xycoords='figure fraction',
horizontalalignment='center', verticalalignment='center', fontsize=14, color='k')
# Plot a 'bracket'
plt.figure()
npoints = 100
td = np.linspace(np.pi*3/4, np.pi*5/4, npoints)
xd = np.cos(td)
yd = np.sin(td)
plt.plot(xd,yd)
编辑: 我相信使用 PathPatch 将是最好的解决方案,就像在这个 Matplotlib example 中一样。我只是不知道该怎么做。
【问题讨论】:
-
可能是这样的answer。似乎最好只有两个子图并在每个子图中绘制四个组,线条由图例/颜色区分。
-
我很确定使用“补丁”可能是一个有效的解决方案,只是不知道该怎么做。
-
@paul-brodersen 你能帮忙找出补丁解决方案吗?
标签: python matplotlib plot draw curve