-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
Code Sample, a copy-pastable example if possible
# Your code here
def plot_outlier_stats(df_joined_spatial,include_std=False):
columns = ["+ Mean","+ Mean (%)","- Mean",'- Mean (%)']
if include_std:
columns += ['+ Std','- Std']
ax = df_joined_spatial[columns].plot(kind="bar",secondary_y=["+ Mean (%)",'- Mean (%)'])
ax.legend(loc='upper center',)
return ax
vals = array([[4.86153846e+01, 1.18689904e+00, 4.35006631e+00, 2.51538462e+01,
6.14107572e-01, 7.54813613e+00],
[6.92307692e+00, 1.69020433e-01, 7.78311782e+00, 2.30769231e+00,
5.63401442e-02, 2.59437261e+00],
[6.15384615e-01, 1.20192308e-01, 1.50213523e+00, 1.53846154e-01,
3.00480769e-02, 3.75533808e-01],
[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.07692308e+00,
4.05649038e-01, 2.77350098e-01],
[6.46153846e+00, 1.26201923e+00, 2.14535874e+00, 2.15384615e+00,
4.20673077e-01, 8.98717034e-01]])
df_test = pd.DataFrame(vals)
df_test.columns = ['+ Mean', '+ Mean (%)', '+ Std', '- Mean', '- Mean (%)', '- Std']
plot_outlier_stats(df_test)
Problem description
The resulting legend should include columns from both axes(["+ Mean","+ Mean (%)","- Mean",'- Mean (%)']); however, it only includes the texts of the left axis.
Expected Output
legend with ["+ Mean","+ Mean (%)","- Mean",'- Mean (%)'] what is return is only ["+ Mean","- Mean"].
Also,
legend = ax.__dict__['legend_'].__dict__["texts"]
returns all texts, but for h1, l1 = ax.get_legend_handles_labels()
l1 = ['+ Mean', '- Mean'] it should be all
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-1005-azure
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.22.0
pytest: 3.0.3
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.26.1
numpy: 1.14.1
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: 1.5.4
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.1
tables: 3.3.0
numexpr: 2.6.1
feather: None
matplotlib: 2.1.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.0
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.2.1
pymysql: None
psycopg2: 2.7.3.1 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: 0.1.3
pandas_gbq: None
pandas_datareader: 0.2.1