geom_crossbar¶from lets_plot import *
LetsPlot.setup_html()
data = {
'vertical_category': ['Without midline', 'Above midline', 'Below midline', 'Above bar', 'Below bar'],
'horisontal_category': ['Without midline', 'Right of midline', 'Left of midline', 'Right of bar', 'Left of bar'],
'ymin': [0, 5, 5, 0, 20],
'ymax': [20, 20, 20, 2, 22],
'y': [None, 6, 19, 1, 21],
'value': [20, 15, 15, 2, 2]
}
ggplot(data) + \
geom_crossbar(
aes(x='vertical_category', y='y', ymin='ymin', ymax='ymax'),
labels=layer_labels(["value"]).size(20))
ggplot(data) + coord_flip() + \
geom_crossbar(
aes(x='horisontal_category', y='y', ymin='ymin', ymax='ymax'),
labels=layer_labels(["value"]).size(20))
Lond text strings that don't fit in the bar are drawn with a background.
ggplot(data) + \
geom_crossbar(
aes(x='vertical_category', y='y', ymin='ymin', ymax='ymax'),
fill='lightblue',
labels=layer_labels(["vertical_category"]).size(20))
ggplot(data) + \
geom_crossbar(
aes(x='vertical_category', y='y', ymin='ymin', ymax='ymax', color="vertical_category"),
show_legend=False,
labels=layer_labels(["value"])
.size(20)
.inherit_color() # <--- Enable using the geometry color in labels.
)