biostats.heatmap#
- biostats.heatmap(data, x, y, value)[source]#
Draw a heat map to show the relation between two categorical variables.
- Parameters:
- data
pandas.DataFrame The input data. Must contain at least one numeric column and two categorical columns.
- x
str The categorical variable to be plotted in x-axis. Maximum 20 groups.
- y
str The categorical variable to be plotted in y-axis. Maximum 20 groups.
- value
str The numeric variable to be plotted with different colors.
- data
- Returns:
- fig
matplotlib.figure.Figure The generated plot.
- fig
See also
histogram_2DDraw a 2D histogram to show the distribution of two numeric variables.
Examples
>>> import biostats as bs >>> import matplotlib.pyplot as plt >>> data = bs.dataset("flights.csv") >>> data year month passengers 0 1949 January 112 1 1949 February 118 2 1949 March 132 3 1949 April 129 4 1949 May 121 .. ... ... ... 139 1960 August 606 140 1960 September 508 141 1960 October 461 142 1960 November 390 143 1960 December 432
We want to visualize the relation between year and month by examining passengers.
>>> fig = bs.heatmap(data=data, x="year", y="month", value="passengers") >>> plt.show()