目前,我正在建造一个有<>Plotly的地块,这表明医生的工程有所转变。 由于这块地块混淆不清,我要对地块作出修改。 是否可能在个别试金星之间添加细微线,以区分白天和医生。
此处为:
def visualize_schedule(days, undercoverage):
dic = {(1, 1, 1): 1.0, (1, 1, 2): 0.0, (1, 1, 3): 0.0, (1, 2, 1): 0.0, (1, 2, 2): 1.0, (1, 2, 3): 0.0, (1, 3, 1): 0.0, (1, 3, 2): 0.0, (1, 3, 3): 0.0, (1, 4, 1): 0.0, (1, 4, 2): 1.0, (1, 4, 3): 0.0, (1, 5, 1): 1.0, (1, 5, 2): 0.0, (1, 5, 3): 0.0, (1, 6, 1): 0.0, (1, 6, 2): 1.0, (1, 6, 3): 0.0, (1, 7, 1): 0.0, (1, 7, 2): 1.0, (1, 7, 3): 0.0, (2, 1, 1): 1.0, (2, 1, 2): 0.0, (2, 1, 3): 0.0, (2, 2, 1): 1.0, (2, 2, 2): 0.0, (2, 2, 3): 0.0, (2, 3, 1): 1.0, (2, 3, 2): 0.0, (2, 3, 3): 0.0, (2, 4, 1): 0.0, (2, 4, 2): 0.0, (2, 4, 3): 0.0, (2, 5, 1): 1.0, (2, 5, 2): 0.0, (2, 5, 3): 0.0, (2, 6, 1): 0.0, (2, 6, 2): 0.0, (2, 6, 3): 1.0, (2, 7, 1): 0.0, (2, 7, 2): 1.0, (2, 7, 3): 0.0, (3, 1, 1): 1.0, (3, 1, 2): 0.0, (3, 1, 3): 0.0, (3, 2, 1): 0.0, (3, 2, 2): 1.0, (3, 2, 3): 0.0, (3, 3, 1): 0.0, (3, 3, 2): 0.0, (3, 3, 3): 0.0, (3, 4, 1): 1.0, (3, 4, 2): 0.0, (3, 4, 3): 0.0, (3, 5, 1): 1.0, (3, 5, 2): 0.0, (3, 5, 3): 0.0, (3, 6, 1): 1.0, (3, 6, 2): 0.0, (3, 6, 3): 0.0, (3, 7, 1): 0.0, (3, 7, 2): 1.0, (3, 7, 3): 0.0}
s = pd.Series(dic)
data = (s.loc[lambda s: s == 1]
.reset_index(-1)[ level_2 ].unstack(fill_value=0)
.reindex(index=s.index.get_level_values(0).unique(),
columns=s.index.get_level_values(1).unique(),
fill_value=0
)
)
data.index = data.index.astype(int)
data.columns = data.columns.astype(str)
title_str = f Physician Schedules | Total Undercoverage: {undercoverage}
fig = px.imshow(data[[str(i) for i in range(1, days + 1)]],
color_continuous_scale=["purple", "orange", "yellow", pink ])
fig.update(data=[{ hovertemplate : "Day: %{x}<br>"
"Physician: %{y}<br>"}])
colorbar = dict(thickness=35,
tickvals=[0, 1, 2, 3],
ticktext=[ Off , Evening , Noon , Morning ])
fig.update(layout_coloraxis_showscale=True, layout_coloraxis_colorbar=colorbar)
x_ticks = np.arange(1, days + 1)
day_labels = [ Day + str(i) for i in x_ticks]
fig.update_xaxes(tickvals=x_ticks, ticktext=day_labels)
y_ticks = np.arange(1, data.shape[0] + 1)
physician_labels = [ Physician + str(i) for i in y_ticks]
fig.update_yaxes(tickvals=y_ticks, ticktext=physician_labels)
fig.update_layout(
title={
text : title_str,
y : 0.98,
x : 0.5,
xanchor : center ,
yanchor : top ,
font : { size : 24}
}
)
fig.update_layout(
xaxis=dict(
showgrid=True,
gridwidth=1.5,
gridcolor= LightGray
),
yaxis=dict(
showgrid=True,
gridwidth=1.5,
gridcolor= LightGray
)
)
fig.show()
return fig