I am currently trying to plot a large amount of data on a single plot. I have structured my representation using repeated colors and symbols. However, when plotting the final re
I also had this problem a couple of times and use this workaround by adding dummy items to the legend to fill the last column, if there are more elegant methods available I would also be very interested to hear about them.
import numpy as np
import matplotlib.pylab as pl
pl.figure()
pl.plot(np.arange(10), np.random.random([10,5]), color='r', label='red')
pl.plot(np.arange(10), np.random.random([10,5]), color='g', label='green')
pl.plot(np.arange(10), np.random.random([10,5]), color='b', label='blue')
pl.plot(np.arange(10), np.random.random([10,2]), color='k', label='black')
# Add empty dummy legend items
pl.plot(np.zeros(1), np.zeros([1,3]), color='w', alpha=0, label=' ')
pl.legend(ncol=4)