src/whylogs/viz/matplotlib/visualizer.py
def plot_uniqueness(self, variable, ts_format="%d-%b-%y", **kwargs):
        """Plots a Estimated Unique Values chart."""
        if not self._confirm_profile_data:
            return

        chart_data = self._summary_data_preprocessing(variable)

        if (
            chart_data.loc[:, "nunique_numbers"].sum() == 0
            and chart_data.loc[:, "nunique_str"].sum() == 0
        ):
            print("No data appropriate for uniqueness plot.")
            return
        elif (
            chart_data.loc[:, "nunique_numbers"].sum()
            > chart_data.loc[:, "nunique_str"].sum()
        ):
            metrics = [
                "nunique_numbers",
                "nunique_numbers_lower",
                "nunique_numbers_upper",
            ]
        else:
            metrics = ["nunique_str", "nunique_str_lower", "ununique_str_upper"]

        fig, ax = MatplotlibProfileVisualizer._chart_theming()

        # Primary line
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[0]],
            color=self.theme["colors"][0],
            linewidth=1.5,
            label="Estimated unique count",
        )

        # Lines bordering the fill area
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[1]],
            color=self.theme["fill_colors"][1],
            linewidth=0.5,
        )
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[2]],
            color=self.theme["fill_colors"][1],
            linewidth=0.5,
        )

        # Fill areas
        ax.fill_between(
            chart_data.loc[:, "date"],
            y1=chart_data.loc[:, metrics[1]],
            y2=chart_data.loc[:, metrics[2]],
            alpha=0.5,
            color=self.theme["fill_colors"][1],
            label="5-95%",
        )

        ax.yaxis.set_label_text("Unique Value Count", fontweight="bold")
        ax.set_title(
            f"Estimated Unique Values ({variable})", loc="left", fontweight="bold"
        )
        handles, labels = ax.get_legend_handles_labels()
        ax.legend(
            handles,
            labels,
            loc="upper center",
            bbox_to_anchor=(0.5, -0.1),
            frameon=False,
            ncol=3,
        )
        ax.xaxis.set_major_formatter(_dates.DateFormatter(ts_format))
        ax.yaxis.set_major_formatter(
            _ticker.ScalarFormatter(useOffset=False, useMathText=False, useLocale=None)
        )

        return fig
Plots a Estimated Unique Values chart.
Plots a Estimated Unique Values chart.
Plots a Estimated Unique Values chart .
def plot_uniqueness(self, variable, ts_format="%d-%b-%y", **kwargs):
        if not self._confirm_profile_data:
            return
        chart_data = self._summary_data_preprocessing(variable)
        if (
            chart_data.loc[:, "nunique_numbers"].sum() == 0
            and chart_data.loc[:, "nunique_str"].sum() == 0
        ):
            print("No data appropriate for uniqueness plot.")
            return
        elif (
            chart_data.loc[:, "nunique_numbers"].sum()
            > chart_data.loc[:, "nunique_str"].sum()
        ):
            metrics = [
                "nunique_numbers",
                "nunique_numbers_lower",
                "nunique_numbers_upper",
            ]
        else:
            metrics = ["nunique_str", "nunique_str_lower", "ununique_str_upper"]
        fig, ax = MatplotlibProfileVisualizer._chart_theming()
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[0]],
            color=self.theme["colors"][0],
            linewidth=1.5,
            label="Estimated unique count",
        )
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[1]],
            color=self.theme["fill_colors"][1],
            linewidth=0.5,
        )
        ax.plot(
            chart_data.loc[:, "date"],
            chart_data.loc[:, metrics[2]],
            color=self.theme["fill_colors"][1],
            linewidth=0.5,
        )
        ax.fill_between(
            chart_data.loc[:, "date"],
            y1=chart_data.loc[:, metrics[1]],
            y2=chart_data.loc[:, metrics[2]],
            alpha=0.5,
            color=self.theme["fill_colors"][1],
            label="5-95%",
        )
        ax.yaxis.set_label_text("Unique Value Count", fontweight="bold")
        ax.set_title(
            f"Estimated Unique Values ({variable})", loc="left", fontweight="bold"
        )
        handles, labels = ax.get_legend_handles_labels()
        ax.legend(
            handles,
            labels,
            loc="upper center",
            bbox_to_anchor=(0.5, -0.1),
            frameon=False,
            ncol=3,
        )
        ax.xaxis.set_major_formatter(_dates.DateFormatter(ts_format))
        ax.yaxis.set_major_formatter(
            _ticker.ScalarFormatter(useOffset=False, useMathText=False, useLocale=None)
        )
        return fig
def plot_uniqueness ( self , variable , ts_format = "%d-%b-%y" , ** kwargs ) : if not self . _confirm_profile_data : return chart_data = self . _summary_data_preprocessing ( variable ) if ( chart_data . loc [ : , "nunique_numbers" ] . sum ( ) == 0 and chart_data . loc [ : , "nunique_str" ] . sum ( ) == 0 ) : print ( "No data appropriate for uniqueness plot." ) return elif ( chart_data . loc [ : , "nunique_numbers" ] . sum ( ) > chart_data . loc [ : , "nunique_str" ] . sum ( ) ) : metrics = [ "nunique_numbers" , "nunique_numbers_lower" , "nunique_numbers_upper" , ] else : metrics = [ "nunique_str" , "nunique_str_lower" , "ununique_str_upper" ] fig , ax = MatplotlibProfileVisualizer . _chart_theming ( ) ax . plot ( chart_data . loc [ : , "date" ] , chart_data . loc [ : , metrics [ 0 ] ] , color = self . theme [ "colors" ] [ 0 ] , linewidth = 1.5 , label = "Estimated unique count" , ) ax . plot ( chart_data . loc [ : , "date" ] , chart_data . loc [ : , metrics [ 1 ] ] , color = self . theme [ "fill_colors" ] [ 1 ] , linewidth = 0.5 , ) ax . plot ( chart_data . loc [ : , "date" ] , chart_data . loc [ : , metrics [ 2 ] ] , color = self . theme [ "fill_colors" ] [ 1 ] , linewidth = 0.5 , ) ax . fill_between ( chart_data . loc [ : , "date" ] , y1 = chart_data . loc [ : , metrics [ 1 ] ] , y2 = chart_data . loc [ : , metrics [ 2 ] ] , alpha = 0.5 , color = self . theme [ "fill_colors" ] [ 1 ] , label = "5-95%" , ) ax . yaxis . set_label_text ( "Unique Value Count" , fontweight = "bold" ) ax . set_title ( f"Estimated Unique Values ({variable})" , loc = "left" , fontweight = "bold" ) handles , labels = ax . get_legend_handles_labels ( ) ax . legend ( handles , labels , loc = "upper center" , bbox_to_anchor = ( 0.5 , - 0.1 ) , frameon = False , ncol = 3 , ) ax . xaxis . set_major_formatter ( _dates . DateFormatter ( ts_format ) ) ax . yaxis . set_major_formatter ( _ticker . ScalarFormatter ( useOffset = False , useMathText = False , useLocale = None ) ) return fig
Plots a Estimated Unique Values chart.
Plots a Estimated Unique Values chart .
"""Plots a Estimated Unique Values chart.""" # Primary line # Lines bordering the fill area # Fill areas
self
variable
ts_format