BarGraph

Contents

BarGraph#

missionbio.plotting.bargraph.BarGraph

class BarGraph(data: Series, palette: Optional[Dict] = None, text: Optional[Sequence] = None, title: str = '')#

Create a horizontal bar graph with ticks and labels. This is used to create the bar graphs in the missionbio.mosaic.sample.Sample.signaturemap() plot.

Snippets#

>>> from missionbio.plotting.bargraph import BarGraph
>>> import pandas as pd
>>> import numpy as np
>>> data = pd.Series([75, 25], index=["a", "b"])
>>> bg = BarGraph(data, text=data.values / 100)
>>> bg.draw()
Parameters:
datapd.Series

The data to plot. The index must be the names of the bars and the values must be the heights of the bars.

paletteOptional[Dict]

A dictionary mapping the index of the data to a color. If None, the default palette is used.

textOptional[Sequence]

A list of text to display on the right of the bars. If None, no value is displayed. If the length of the list is less than the length of the data, the remaining values are not displayed.

titlestr

The title of the plot