plotnine.geoms.geom_col

class plotnine.geoms.geom_col(mapping: Aes | None = None, data: DataLike | None = None, **kwargs: Any)[source]

Bar plot with base on the x-axis

This is an alternate version of geom_bar that maps the height of bars to an existing variable in your data. If you want the height of the bar to represent a count of cases, use geom_bar.

Usage

geom_col(mapping=None, data=None, stat='identity', position='stack',
         na_rm=False, inherit_aes=True, show_legend=None, raster=False,
         width=None, **kwargs)

Only the data and mapping can be positional, the rest must be keyword arguments. **kwargs can be aesthetics (or parameters) used by the stat.

Parameters
mappingaes, optional

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

1

color

None

fill

'#595959'

group

linetype

'solid'

size

0.5

The bold aesthetics are required.

datadataframe, optional

The data to be displayed in this layer. If None, the data from from the ggplot() call is used. If specified, it overrides the data from the ggplot() call.

statpython:str or stat, optional (default: stat_identity)

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.

positionpython:str or position, optional (default: position_stack)

Position adjustment. If it is a string, it must be registered and known to Plotnine.

na_rmbool, optional (default: python:False)

If False, removes missing values with a warning. If True silently removes missing values.

inherit_aesbool, optional (default: python:True)

If False, overrides the default aesthetics.

show_legendbool or python:dict, optional (default: python:None)

Whether this layer should be included in the legends. None the default, includes any aesthetics that are mapped. If a bool, False never includes and True always includes. A dict can be used to exclude specific aesthetis of the layer from showing in the legend. e.g show_legend={'color': False}, any other aesthetic are included by default.

rasterbool, optional (default: python:False)

If True, draw onto this layer a raster (bitmap) object even ifthe final image is in vector format.

widthpython:float, (default: python:None)

Bar width. If None, the width is set to 90% of the resolution of the data.