如何使用 Bokeh 在 Holoview 上将文本旋转为水平
How to rotate text to be horizontal on Holoview with Bokeh
在https://holoviews.org/gallery/demos/bokeh/route_chord.html的例子中,
如何将弧标签的方向更改为水平方向?不重叠的奖励积分 - 或者使用单独图例的替代方案
@philippjfr 来自 gitter 的回答是:
# %%opts Chord [edge_color_index='SourceID' label_index='City' color_index='AirportID' width=800 height=800]
# %%opts Chord (cmap='Category20' edge_cmap='Category20')
def rotate_label(plot, element):
text_cds = plot.handles['text_1_source']
length = len(text_cds.data['angle'])
text_cds.data['angle'] = [0]*length
xs = text_cds.data['x']
text = np.array(text_cds.data['text'])
xs[xs<0] -= np.array([len(t)*0.019 for t in text[xs<0]])
busiest_airports.options(
edge_color_index='SourceID', label_index='City', color_index='AirportID',
width=800, height=800, finalize_hooks=[rotate_label], cmap='Category20',
edge_cmap='Category20'
)
在https://holoviews.org/gallery/demos/bokeh/route_chord.html的例子中, 如何将弧标签的方向更改为水平方向?不重叠的奖励积分 - 或者使用单独图例的替代方案
@philippjfr 来自 gitter 的回答是:
# %%opts Chord [edge_color_index='SourceID' label_index='City' color_index='AirportID' width=800 height=800]
# %%opts Chord (cmap='Category20' edge_cmap='Category20')
def rotate_label(plot, element):
text_cds = plot.handles['text_1_source']
length = len(text_cds.data['angle'])
text_cds.data['angle'] = [0]*length
xs = text_cds.data['x']
text = np.array(text_cds.data['text'])
xs[xs<0] -= np.array([len(t)*0.019 for t in text[xs<0]])
busiest_airports.options(
edge_color_index='SourceID', label_index='City', color_index='AirportID',
width=800, height=800, finalize_hooks=[rotate_label], cmap='Category20',
edge_cmap='Category20'
)