import numpy as np
import matplotlib.pyplot as plt

from cellcomplex.property_topomesh.example_topomesh import hexagon_topomesh
from cellcomplex.property_topomesh.utils.matplotlib_tools import mpl_draw_topomesh, mpl_draw_incidence_graph

topomesh = hexagon_topomesh()
topomesh.update_wisp_property('random',2,dict(zip(topomesh.wisps(2),np.random.rand(topomesh.nb_wisps(2)))))

figure = plt.figure(0)
figure.clf()
figure.gca().axis('equal')

col = mpl_draw_topomesh(topomesh,figure,2,property_name='random',colormap='viridis',intensity_range=(0,1))
mpl_draw_topomesh(topomesh,figure,1,color='k')
mpl_draw_topomesh(topomesh,figure,0,color='k')

figure.colorbar(col)

figure.gca().axis('off')
figure.tight_layout()