position_fill#
- position_fill(vjust=None, mode=None)#
Adjust position by stacking overlapping objects on top of each other and standardise each stack to have constant height.
- Parameters:
- vjustfloat, default=1.0
Vertical adjustment for geoms that have a position (like points or lines), not a dimension (like bars or areas). Set to 0 to align with the bottom, 0.5 for the middle, and 1 for the top.
- mode{‘groups’, ‘all’}, default=’groups’
If ‘groups’, objects inside one group are positioned as in
position='identity', but each group is shifted to sum of heights of previous groups (where height of a group is a maximum of it’s y values). If ‘all’, each object will be shifted.
- Returns:
FeatureSpecGeom object position specification.
Notes
Adjust position by stacking overlapping objects on top of each other and standardise each stack to have constant height.
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3data = { 4 'x': [1, 1, 1, 1, 1, 2, 2, 2], 5 'y': [1, 2, 1, 3, 5, 1, 2, 2], 6 'g': ["a", "a", "b", "b", "b", "a", "a", "b"], 7} 8gggrid([ 9 ggplot(data, aes('x', 'y', fill='g')) + \ 10 geom_label(aes(label='y'), size=10, 11 color="white", show_legend=False, 12 position=position_fill(mode='groups')) + \ 13 coord_cartesian(ylim=[0, 1.1]) + \ 14 ggtitle("mode='groups'"), 15 ggplot(data, aes('x', 'y', fill='g')) + \ 16 geom_label(aes(label='y'), size=10, 17 color="white", show_legend=False, 18 position=position_fill(mode='all')) + \ 19 coord_cartesian(ylim=[0, 1.1]) + \ 20 ggtitle("mode='all'"), 21])