【发布时间】:2021-02-20 00:32:05
【问题描述】:
我有一个 plotly express facet_row 图,其中包含三个子图,效果很好。我想在为绘图的特定区域着色并添加文本的所有行中添加一个框。 add_vrect 应该可以完成这项工作,但我很难让它工作。
https://plotly.com/python/horizontal-vertical-shapes/ https://plotly.com/python/facet-plots/
下面的代码
import pandas as pd
import plotly.express as px
import plotly.io as pio
ftir_data_facet = pd.read_csv(r"C:\Users\mch047\Box Sync\PhD project Mikkel C\OneDrive - UiT Office 365\Mikkel_Christensen\Bioinformatics\Paper 1\Figure 2 Plate screen panel\Full_FTIR_dataset\Paper1_Figure2_FTIR_tidy_faceformat_071120.csv", sep=";")
#ftir_data_facet
figure2_facet = px.scatter(ftir_data_facet, x="Wavenumbers (1/cm)", y="Absorbance", color="Strain", facet_row="Plate")
figure2_facet.update_xaxes(title_text="Wavenumbers (1/cm)", range=[4000, 1000], showgrid=False)
fig.show()
我已尝试添加:
figure2_facet.add_vrect(x0="1750", x1="1700", row=All,
annotation_text="Carbonyl region", annotation_position="top left",
fillcolor="green", opacity=0.25, line_width=0)
我明白了:
"AttributeError: 'Figure' 对象没有属性 'add_vrect'"
任何人都可以帮助或解释为什么它不起作用..?
【问题讨论】: