from plotnine import ggplot, aes, geom_bar, labs, coord_flip, theme_classic
from plotnine.data import mpg plotnine.geom_bar
Bar plot
geom_bar(
mapping=None,
data=None,
*,
stat="count",
position="stack",
na_rm=False,
inherit_aes=True,
show_legend=None,
raster=False,
just=0.5,
width=None,
**kwargs
)Parameters
mapping : aes = None-
Aesthetic mappings created with aes. If specified and
inherit_aes=True, it is combined with the default mapping for the plot. You must supply mapping if there is no plot mapping.Aesthetic Default value x y alpha 1color Nonefill '#595959'group linetype 'solid'size 0.5The bold aesthetics are required.
data : DataFrame = None-
The data to be displayed in this layer. If
None, the data from from theggplot()call is used. If specified, it overrides the data from theggplot()call. stat : str | stat = "count"-
The statistical transformation to use on the data for this layer. If it is a string, it must be the registered and known to Plotnine.
position : str | position = "stack"-
Position adjustment. If it is a string, it must be registered and known to Plotnine.
na_rm : bool = False-
If
False, removes missing values with a warning. IfTruesilently removes missing values. inherit_aes : bool = True-
If
False, overrides the default aesthetics. show_legend : bool | dict = None-
Whether this layer should be included in the legends.
Nonethe default, includes any aesthetics that are mapped. If abool,Falsenever includes andTruealways includes. Adictcan be used to exclude specific aesthetis of the layer from showing in the legend. e.gshow_legend={'color': False}, any other aesthetic are included by default. raster : bool = False-
If
True, draw onto this layer a raster (bitmap) object even ifthe final image is in vector format. just : float = 0.5-
How to align the column with respect to the axis breaks. The default
0.5aligns the center of the column with the break.0aligns the left of the of the column with the break and1aligns the right of the column with the break. width : float = None-
Bar width. If
None, the width is set to90%of the resolution of the data. **kwargs : Any-
Aesthetics or parameters used by the
stat.
See Also
geom_histogramstat_count-
The default
statfor thisgeom.




