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(data, title=None, cmap='viridis', xlabel=None, ylabel=None) Create a heatmap using a pandas DataFrame or a 2D NumPy array. :param data: Input data for the heatmap. Can be a pandas DataFrame or a 2D NumPy array. The data should be numeric; non-numeric values will cause errors. :type data: pandas.DataFrame or numpy.ndarray :param title: Title of the heatmap. Default is None. :type title: str, optional :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 is not a pandas DataFrame or a NumPy array. :raises ValueError: If the input data is empty or contains non-numeric values. .. rubric:: Examples Using a pandas DataFrame: >>> 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") Using a NumPy array: >>> arr = np.random.rand(5, 5) >>> fig, ax = plot_heatmap(arr, title="Heatmap from NumPy array")