Created
September 1, 2016 14:16
-
-
Save showa-yojyo/85f0033c50c48c8ee6e8531312315062 to your computer and use it in GitHub Desktop.
Demonstrate mpl.sankey.Sankey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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