def test_repeated_finish(self, fig_test, fig_ref): # Make sure that repeated finish calls do not change the styling from pyalluv import Alluvial # ### # refax refax = fig_ref.subplots() a = Alluvial.from_memberships( [[0, 1, 1, 2], [3, 0, 1, 2], [1, 0, 1, 1]], layout='centered', blockprops=dict(width=0.2), hspace_combine='divide', ax=refax) # Alluvial.from_memberships calls finish already, a second call should # not lead t any changes tesax = fig_test.subplots() a = Alluvial.from_memberships( [[0, 1, 1, 2], [3, 0, 1, 2], [1, 0, 1, 1]], layout='centered', blockprops=dict(width=0.2), hspace_combine='divide', ax=tesax) # here, we call finish again a.finish() refax.set_xlim(-1, 4) tesax.set_xlim(-1, 4) refax.set_ylim(-6, 10) tesax.set_ylim(-6, 10)
def test_yoff(self, flows, ext, fractf, layout, ref_columns): # from pyalluv import Alluvial a = Alluvial.from_memberships( [[0, 1, 1, 2], [3, 0, 1, 2], [1, 0, 1, 1]], layout='centered', blockprops=dict(width=0.2), hspace_combine='divide') a.add_from_memberships([[0, 1, 1, 2], [3, 0, 1, 2], [1, 0, 1, 1]], layout='top', blockprops=dict(width=0.2), hspace_combine='divide', yoff=-4) a.add_from_memberships([[0, 1, 1, 2], [3, 0, 1, 2], [1, 0, 1, 1]], layout='bottom', blockprops=dict(width=0.2), hspace_combine='divide', yoff=4) a.finish() a.ax.set_xlim(-1, 4) a.ax.set_ylim(-6, 10)
""" import numpy as np # from matplotlib.alluvial import Alluvial from pyalluv import Alluvial import matplotlib.pyplot as plt # Consider a small network of 4 nodes with membership lists at 3 point in time: memberships = [ [0, 1, 1, 2], # t1 [3, 0, 1, 2], # t2 [1, 0, 1, 1] ] # t3 # Create an alluvial diagram based on the memberships Alluvial.from_memberships(memberships, layout='top', x=['t1', 't2', 't3'], width=0.2) plt.show() ############################################################################# # ========================== # Alluvial Demo - Flow based # ========================== # # Draw Alluvial using flow matrices # import matplotlib.pyplot as plt import numpy as np # from matplotlib.alluvial import Alluvial from pyalluv import Alluvial
np.hstack((ref_nodes, new_affiliation(initial_affiliation))) ) dcs.append(ref_nodes) # TODO: # Multiple plots # # layout bottom # # layout centered # # layout optimized # # as subd's fig, axs = plt.subplots(2, 2) # layout bottom alluvial = Alluvial.from_memberships(memberships, dcs=dcs, ax=axs[0][0], x=x, layout='bottom', hspace_combine='divide', blockprops=dict(width=0.2)) # layout centered alluvial = Alluvial.from_memberships(memberships, dcs=dcs, ax=axs[0][1], x=x, layout='centered', hspace_combine='divide', blockprops=dict(width=0.2)) # layout optimized alluvial = Alluvial.from_memberships(memberships, dcs=dcs, ax=axs[1][0], x=x, layout='optimized', hspace_combine='divide', blockprops=dict(width=0.2)) # separated dcs into subds # TODO
def test_memberships_conversion(self, memberships, ref_columns, ref_flows): alluvial = Alluvial.from_memberships(memberships, layout='centered', blockprops=dict(width=0.3)) alluvial.finish() _test_block_ordering(alluvial, ref_columns)