dsci_524_ezplot.plot_heatmap ============================ .. py:module:: dsci_524_ezplot.plot_heatmap Functions --------- .. autoapisummary:: dsci_524_ezplot.plot_heatmap.plot_heatmap Module Contents --------------- .. py:function:: plot_heatmap(df, title=None, cmap='viridis', xlabel=None, ylabel=None) Create a heatmap using data from a pandas DataFrame or a 2D array. :param df: Input data for the heatmap. Can be a pandas DataFrame or a 2D NumPy array. The data should be numeric, as non-numeric values will cause errors. :type df: pandas.DataFrame or numpy.ndarray :param title: Title of the heatmap. :type title: str :param cmap: Colormap for the heatmap. Defaults to 'viridis'. :type cmap: str, optional :param xlabel: Label for the x-axis. Defaults to None. :type xlabel: str, optional :param ylabel: Label for the y-axis. Defaults to None. :type ylabel: str, optional :returns: - matplotlib.figure.Figure The figure object containing the heatmap. - matplotlib.axes.Axes The axes object containing the heatmap elements. :rtype: tuple :raises TypeError: If the input data contains non-numeric values. :raises ValueError: If the input data is empty. .. rubric:: Examples >>> import pandas as pd >>> import numpy as np >>> df = pd.DataFrame(np.random.rand(5, 5), columns=['A', 'B', 'C', 'D', 'E']) >>> fig, ax = plot_heatmap(df, title="Sample Heatmap", xlabel="Columns", ylabel="Rows")