English 中文(简体)
在地貌图中添加细微的子体
原标题:Add thin lines inbetween rectangles in plotly figure

目前,我正在建造一个有<>Plotly的地块,这表明医生的工程有所转变。 由于这块地块混淆不清,我要对地块作出修改。 是否可能在个别试金星之间添加细微线,以区分白天和医生。

“entergram

此处为:

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
问题回答




相关问题
How to reduce decimal places in bar in Plotly express?

i need your help to reduce decimal places to 2 in my bar chart created by Ployly Express. enter image description here my code is: fig8 = px.bar( new_data, x=["Loyal", "Exited"]...

Embedding tweets in D3 tooltip

I m trying to build a custom D3 tooltip that displays a tweet widget using the copy/paste code from publish.twitter.com. I m setting up plots using plotly in R and would like a tweet widget to be ...

Treemaps With Plotly: Blank Screen

I am working with the R programming language. I am trying to plot a Treemap with plotly, but it s returning a blank screen I made my own dataset for this problem: dados <- data.frame( Marca = c(...

size legend for plotly bubble map/chart

Here is a plotly "bubble" map (i.e. a map with markers on it, whose size is mapped to a variable). However, the legend only shows the color categories, but does not show how size relates to value. ...

Select/copy hover text in R plotly graph

I would like to be able to select and copy the hover text in plotly graphs. Is that possible with the R API? For example, in this heatmap, upon mousing over coordinates (X=a, Y=d), one can see the ...

热门标签