我试图用Plotly绘制一个bupar Precedence Matrix,如下所示.
到目前为止,我试图绘制如下散点图:
import plotly.express as px
fig = px.scatter(df,
y="Antecedent",
x="Consequent",
size="Absolute_Frequency",
color="Absolute_Frequency")
fig.update_traces(
hovertemplate="<br>".join([
"Antecedent: %{y}",
"Consequent: %{x}"
]),
name=""
)
fig.update_layout(
template="plotly_white",
# Figure title styling
title= dict(
text="Precedence Matrix",
x=0.5,
y=0.95,
font=dict(
family="Rockwell",
size=20,
color='#000000'
)
),
xaxis_title="Consequent",
yaxis_title="Antecedent",
font=dict(
family="Rockwell",
size=16),
# Fig height
height=600,
width=1200,
# Turn off legend
showlegend=False,
hoverlabel=dict(
bgcolor="white",
font_size=16,
font_family="Rockwell"
)
)
fig.show()
如何在plotly中添加文本注释并按照bupar Precedence Matrix
创建矩形?
Antecedent | Consequent | Absolute_Frequency |
---|---|---|
register request | examine thoroughly | 1 |
examine thoroughly | check ticket | 2 |
check ticket | decide | 6 |
decide | reject request | 3 |
register request | check ticket | 2 |
check ticket | examine casually | 2 |
examine casually | decide | 2 |
decide | pay compensation | 3 |
register request | examine casually | 3 |
examine casually | check ticket | 4 |
decide | reinitiate request | 3 |
reinitiate request | examine thoroughly | 1 |
check ticket | examine thoroughly | 1 |
examine thoroughly | decide | 1 |
reinitiate request | check ticket | 1 |
reinitiate request | examine casually | 1 |