From d04d8da07f029fd2931f48d2f7f324cf393e5277 Mon Sep 17 00:00:00 2001 From: Aniruddha Banerjea <29407246+Ban-zee@users.noreply.github.com> Date: Fri, 26 Apr 2019 18:04:43 +0530 Subject: [PATCH] Fixed KDE Legend (#652) --- arviz/plots/kdeplot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arviz/plots/kdeplot.py b/arviz/plots/kdeplot.py index 0baf081c93..8ce4d21fa6 100644 --- a/arviz/plots/kdeplot.py +++ b/arviz/plots/kdeplot.py @@ -2,6 +2,7 @@ import warnings import numpy as np import matplotlib.pyplot as plt +from matplotlib.patches import Patch from scipy.signal import gaussian, convolve, convolve2d # pylint: disable=no-name-in-module from scipy.sparse import coo_matrix import xarray as xr @@ -167,6 +168,7 @@ def plot_kde( plot_kwargs.setdefault("color", "C0") default_color = plot_kwargs.get("color") + if fill_kwargs is None: fill_kwargs = {} @@ -227,7 +229,8 @@ def plot_kde( fill_func(fill_x, fill_y, **fill_kwargs) if legend and label: - ax.legend() + legend_element = [Patch(edgecolor=default_color, label=label)] + ax.legend(handles=legend_element) else: if contour_kwargs is None: contour_kwargs = {}