Skip to content

Instantly share code, notes, and snippets.

@showa-yojyo
Created September 1, 2016 14:16
Show Gist options
  • Save showa-yojyo/85f0033c50c48c8ee6e8531312315062 to your computer and use it in GitHub Desktop.
Save showa-yojyo/85f0033c50c48c8ee6e8531312315062 to your computer and use it in GitHub Desktop.
Demonstrate mpl.sankey.Sankey
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""sankeydemo_mahjong.py:
Usage:
sankeydemo_mahjong.py
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from matplotlib.sankey import Sankey
FONT_PROP = FontProperties(fname=r'C:\WINDOWS\Fonts\HGRME.TTC')
def main():
sankey = Sankey()
sankey.add(flows=[-1100, 500],
labels=['西家', '東家'],
pathlengths=[1100/4, 500*2], lw=0)
sankey.add(flows=[300, 300],
labels=['南家', '北家'],
pathlengths=[300*2, 300*2],
orientations=[-1, 1,], lw=0)
diagrams = sankey.finish()
for diagram in diagrams:
for text in diagram.texts:
text.set_fontproperties(FONT_PROP)
plt.title("東一局", fontproperties=FONT_PROP)
plt.show()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment