Convert a thematic map into png format with a legend
        :param outpath: if specified, will save the image instead of showing it

def make_thematic_png(self, outpath=None):
        """
        Convert a thematic map into png format with a legend
        :param outpath: if specified, will save the image instead of showing it
        """
        from matplotlib.patches import Patch

        fig, previewax = plt.subplots()
        shape = self.thmap.shape
        previewax.imshow(self.thmap,
                         origin='lower',
                         interpolation='nearest',
                         cmap=self.config.solar_cmap,
                         vmin=-1, vmax=len(self.config.solar_classes)-1)

        legend_elements = [Patch(facecolor=c, label=sc, edgecolor='k')
                           for sc, c in self.config.solar_colors.items()]
        previewax.legend(handles=legend_elements, fontsize='x-small',
                         bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
                         ncol=2, mode="expand", borderaxespad=0.)
        previewax.set_xlim([0, shape[0]])
        previewax.set_ylim([0, shape[0]])
        previewax.set_aspect("equal")
        previewax.set_axis_off()

        if outpath:
            fig.savefig(outpath, dpi=300,
                        transparent=True,
                        bbox_inches='tight',
                        pad_inches=0.)
            plt.close()
        else:
            plt.show()