简体   繁体   English

rbokeh将另一个图层字形添加到映射图例

[英]rbokeh add another layer glyph to a mapped legend

I am working in flexdashboards using rbokeh to create dynamic interactive graphs and charts on a series of health related dashboards. 我正在使用rbokehflexdashboards工作,以在一系列与健康相关的仪表板上创建动态的交互式图形和图表。

My current dilemma revolves around adding a line to a stacked bar chart with mapped color values and having it show up in the legend. 我当前的困境是围绕一条线添加一条具有映射的颜色值的堆叠条形图,并使其显示在图例中。

That bar chart is working flawlessly. 该条形图工作正常。

But when I add a pair of ab-lines to separate regions of the x-axis where a change in methods of collection occur, I cannot find a way to get the line to show up in the mapped legend. 但是,当我在x轴的分离区域添加一对ab线时,收集方法发生了变化,我找不到找到使该线显示在映射图例中的方法。

Any attempt to coerce it returns NO CHART at all... 任何试图强迫它的尝试都不会返回任何结果。

Completely stumped and would love some help! 完全陷入困境,并希望获得帮助!

CODE: 码:

 figure(title= "Confirmed & Probable Cases by Year",tools =c("pan","box_zoom", "reset", "save"), width= 1650, height =950, legend_location='top_left',toolbar_location = "above")%>%
          ly_bar(x=Year, y= count, position='stack', data=probConf, width=.9, hover=TRUE, legend=TRUE, fill_alpha=.7, color=Classification) %>%
          ly_abline(v=17.5, color = "red",  width =1, alpha=.7)%>%
          ly_abline(v=13.5, color = "red",  width =1, alpha=.7, legend ="Change in Case Definition")%>%
          set_palette(discrete_color = pal_color(c( "#336699","#339999")))%>%
          x_axis(label ='Year', grid=FALSE)%>%
          y_axis(label ='Cases',grid=FALSE)

With this: , legend ="Change in Case Definition" in there, I get NO CHART at all, just white. 有了这个: , legend ="Change in Case Definition" ,我什么都没有,只是白色。

With ly_abline(v=13.5, color = "red", width =1, alpha=.7)%>% I get a nice chart with no lines on the legend, as in the photograph below. 使用ly_abline(v=13.5, color = "red", width =1, alpha=.7)%>%我得到了一个漂亮的图表,图例上没有线条,如下图所示。 不带底线的图例示例

With: ly_abline(v=13.5, color = "red", width =1, alpha=.7, legend = TRUE)%>% 使用: ly_abline(v=13.5, color = "red", width =1, alpha=.7, legend = TRUE)%>%

I get no chart at all (but no error code, just a vast expanse of white) 我根本没有任何图表(但是没有错误代码,只有大量的白色)

Unfortunately currently in rbokeh (as of v0.5.1) legends that contain mapped attributes and custom legends cannot be mixed. 不幸的是,当前在rbokeh (从v0.5.1版本开始)中,不能将包含映射属性和自定义图例的图例混在一起。 To accomplish this right now you could instead of using ly_bar() , use the lower level ly_rect() with a custom legend to draw the rectangles for each bar color. 要立即完成此操作,您可以代替使用ly_bar() ,而将较低级别的ly_rect()与自定义图例一起使用,以绘制每种条形颜色的矩形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM