Skip to content

Commit

Permalink
Fixed KDE Legend (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ban-zee authored and aloctavodia committed Apr 26, 2019
1 parent 132db50 commit d04d8da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arviz/plots/kdeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit d04d8da

Please sign in to comment.