Note that there are some explanatory texts on larger screens.

plurals
  1. POmatplotlib: figlegend legend is empty box after upgrade to matplotlib 1.1.x
    primarykey
    data
    text
    <p>After upgrading our matplotlib version, we now get empty legends using <code>figlegend()</code>. It just displays an empty box like so:</p> <p><img src="https://i.stack.imgur.com/JpucY.png" alt="enter image description here"></p> <p>I have seen <a href="http://matplotlib.1069221.n5.nabble.com/Legend-and-proxy-artists-td15967.html" rel="nofollow noreferrer">this</a> and <a href="https://stackoverflow.com/questions/10557614/matplotlib-figlegend-only-printing-first-letter">this</a>, but neither has helped me so far.</p> <p>I am using the function </p> <pre><code>handles, labels = ax.get_legend_handles_labels() </code></pre> <p>and this worked fine previously. Everything else works as expected.</p> <p>I have included a very stripped down excerpt from the code which I hope illustrates how we are handling the legends.</p> <pre><code>figprops = dict(figsize=(gsp.plotSizeX, gsp.plotSizeY), dpi=gsp.plotSizeDPI, facecolor='#FFFFFF', edgecolor='#000000', linewidth=0.5, frameon=True) fig = plt.figure(**figprops) fig.autofmt_xdate(bottom = 0.2, rotation = 30, ha='right') canvas = FigureCanvas(fig) legHandles = [] legText = [] font= FontProperties(size='xx-small') hostPlots = [] pcount = len(gsp.subPlots) pn = 111 if pcount &gt; 1: for i in range(1, pcount + 1): pn = pcount * 100 + (1 * 10) + i if i &gt; 1: hostPlots.append(host_subplot(pn, axes_class = AA.Axes, sharex = hostPlots[0])) else: hostPlots.append(host_subplot(pn, axes_class = AA.Axes)) else: hostPlots.append(host_subplot(pn, axes_class = AA.Axes)) adjustprops = dict(bottom=0.10, right=0.70, wspace=0.2, hspace=0.2) # Subplot properties fig.subplots_adjust(**adjustprops) spno = 0 for sp in gsp.subPlots: series = 0 axes_offset = 0 minTicks = sp.axes[0].minTicks majTicks = sp.axes[0].majTicks for a in sp.axes: if series == 0: ax = hostPlots[sp.plotNo-1] p, = ax.plot_date(plotDate, y, 'k', linewidth = a.lineWidth, color = a.lineColor, label = a.axesLabel, linestyle = a.lineType) h, l = ax.get_legend_handles_labels() legHandles.append(h) legText.append(a.axesLegend) else: # if plotType = 'paraPlot' or plotType = 'subPlot' ax = hostPlots[sp.plotNo-1].twinx() p, = ax.plot_date(plotDate, y, 'k', linewidth = a.lineWidth, color = a.lineColor, label = a.axesLabel, linestyle = a.lineType) h, l = ax.get_legend_handles_labels() legHandles.append(h) legText.append(a.axesLegend) trans = transforms.blended_transform_factory(ax.transData, ax.transAxes) rect = patches.Rectangle((dtn, 0), width=1, height=1,transform=trans, color='yellow', alpha=0.333) ax.add_patch(rect) series += 1 spno += 1 pl = hostPlots[spno-1] box = pl.get_position() pl.set_position([box.x0, box.y0 + box.height * 0.1, box.width, box.height * 0.85]) ax = hostPlots[0] ax.set_title( gsp.plotName) #'Time series Data from CWMS Web Service') if gsp.tightLayout: plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=1.0) figlegend(legHandles, (legText,), 'upper center', bbox_to_anchor=(0.40, 0.07), prop=font, ncol=2) </code></pre> <p>Has anyone else seen/fixed the same issue after upgrading using <code>get_legend_handles_labels()</code> and <code>figlegend()</code>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload