proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.11k stars 102 forks source link

Legend facecolor has no effect #402

Closed AWSisco closed 1 year ago

AWSisco commented 1 year ago

Description

Legend facecolor has no effect, but fc appears to work.

Steps to reproduce

import proplot as pplt

fig, axs = pplt.subplots(ncols=2)

for i in range(0,2):
    axs[i].plot((0,1),(-0.5,0.5), label='a', c='k', cycle_kw={'ls': ('-','--',':')})
    axs[i].plot((0,1),(0,1), label='b')
    axs[i].plot((0,1),(0.5,1.5), label='c')

    if i==0:
        axs[i].legend(fc='yellow',ncol=2,order='F',fontsize='large',loc='lr')
    else:
        axs[i].legend(facecolor='yellow',ncol=2,order='F',fontsize='large',loc='lr')

axs.format(ylim=(-1,2),title=('fc','facecolor'))

image

Equivalent steps in matplotlib

import matplotlib.pyplot as plt
fig, ax = plt.subplots()

ax.plot((0,1),(-0.5,0.5),c='k',label='a')
ax.plot((0,1),(0,1),c='k',ls='--',label='b')
ax.plot((0,1),(0.5,1.5),c='k',ls=':',label='c')

ax.legend(facecolor='yellow',fontsize='large')

image

Proplot version

matplotlib 3.5.1 proplot 0.9.5.post301

lukelbd commented 1 year ago

Thanks for the report. This was a very simple fix: ab6affd. Result:

import proplot as pplt

fig, axs = pplt.subplots(ncols=2)

for i in range(0,2):
    axs[i].plot((0,1),(-0.5,0.5), label='a', c='k', cycle_kw={'ls': ('-','--',':')})
    axs[i].plot((0,1),(0,1), label='b')
    axs[i].plot((0,1),(0.5,1.5), label='c')

    if i==0:
        axs[i].legend(fc='yellow',ncol=2,order='F',fontsize='large',loc='lr')
    else:
        axs[i].legend(facecolor='yellow',ncol=2,order='F',fontsize='large',loc='lr')

axs.format(ylim=(-1,2),title=('fc','facecolor'))

iTerm2 VEDrjM tmp2y73w39d