複数の色を使用してx軸上の領域を強調表示しようとしています。私は、この図に示すように、x軸に沿って領域を区切って解を見つけることに成功しました。しかし、代わりにy軸上で区切りが起きている解決策が必要です。プロットの6362を例に挙げてください。他のすべてのダッシュ(またはそれが何であれ)が紫色と赤色である破線のバーのようなものを作成する方法はありますか?Pyplot axvspan:複数の色を1つのスパンに(垂直方向に)
編集 ここでは、それぞれの「ダッシュ」を作成するaxvspan
にymin
とymax
オプションを使用してこれを行うことができ、水平
# Find exon's index
e_index = sorted(list(all_samples.ensembl_exon_id.unique())).index(exon)
# Total x-axis span incl offsets
xmin = e_index-0.25 # Start of x-span
xmax = e_index+0.25 # End of x-span
diff = xmax-xmin # Length of entire span
buf = diff/len(s_names) # Length of each subsection
# Go through each sample
for sname in s_names:
# Get color of this sample
s_color = colors[sname]
# Get index of this sample
order = list(s_names).index(sname)
# Calc xmin and xmax for subsection
s_xmin = xmin + (buf * order)
s_xmax = s_xmin + buf
# Highlight
plt.axvspan(xmin=s_xmin, xmax=s_xmax, alpha=0.25, color=s_color, zorder=0.6, ymin=0, ymax=1)
あなたは私が思うのパッチを使用していることを構築する必要があります。 – armatita
@armatita申し訳ありません、パッチを見ていきましょう、ありがとう。私はあなたが見てみたい場合は、現在強調表示をしている方法のコードを追加しました。 – Plasma