尝试作图5


# -*- coding: utf-8 -*-
"""
Created on Sun Jan  9 17:13:01 2022

@author: Administrator
"""

import matplotlib.pyplot as plt
import matplotlib
import matplotlib.gridspec as gridspec
matplotlib.rcParams['font.family'] = 'FangSong'

jihe = {'干支': '辛丑年辛丑月甲子日己巳時', '旬首': '戊', '旬空': {'日空': '戌亥', '時空': '戌亥'}, '局日': '甲己日', '排局': '陽遁二局上元', '節氣': '小寒', '值符值使': {'值符星宮': ['芮', '震'], '值使門宮': ['死', '兌']}, '天乙': '沖', '天盤': [{'震': '戊', '巽': '癸', '離': '壬', '坤': '乙', '兌': '丁', '乾': '己', '坎': '庚', '艮': '丙'}, {'震': '辛'}], '地盤': {'坤': '戊', '震': '己', '巽': '庚', '中': '辛', '乾': '壬', '兌': '癸', '艮': '丁', '離': '丙', '坎': '乙'}, '門': {'兌': '死', '乾': '驚', '坎': '開', '艮': '休', '震': '生', '巽': '傷', '離': '杜', '坤': '景'}, '星': {'震': '禽', '巽': '柱', '離': '心', '坤': '蓬', '兌': '任', '乾': '沖', '坎': '輔', '艮': '英'}, '神': {'震': '符', '巽': '蛇', '離': '陰', '坤': '合', '兌': '勾', '乾': '雀', '坎': '地', '艮': '天'}, '馬星': {'天馬': '寅', '丁馬': '卯', '驛馬': '亥'}, '長生運': {'天盤': {'震': {'戊': '養'}, '巽': {'癸': '沐浴'}, '離': {'壬': '長生'}, '坤': {'乙': '帝旺'}, '兌': {'丁': '死'}, '乾': {'己': '墓'}, '坎': {'庚': '絕'}, '艮': {'丙': '病'}}, '地盤': {'坤': {'戊': '養'}, '震': {'己': '墓'}, '巽': {'庚': '絕'}, '中': {'辛': '胎'}, '乾': {'壬': '長生'}, '兌': {'癸': '沐浴'}, '艮': {'丁': '死'}, '離': {'丙': '病'}, '坎': {'乙': '帝旺'}}}}
gs = gridspec.GridSpec(3, 3)

def paipan(x):
    plt.xticks([])
    plt.yticks([])
    global dipan, tianpan, men
#地盘干
    dipan = jihe['地盤'][x] 
    plt.text(0.65, 0.1, dipan)

#天盘干
    tianpan = jihe['天盤'][0][x]
    plt.text(0.65, 0.3, tianpan)
#    tianpan0 = jihe['天盤'][1][x]
#    if tianpan0 == jihe['地盤']['中']:
#        plt.text(0.65, 0.3, tianpan0)


    men = jihe['門'][x]
    plt.text(0.4, 0.1, men)

    xing = jihe['星'][x]
    plt.text(0.4, 0.3, xing)
    
    if xing == '禽':
        plt.text(0.5, 0.3, '芮')

    shen = jihe['神'][x]
    if shen == '勾':
        plt.text(0.4, 0.5, '虎')
    elif shen == '雀':
        plt.text(0.4, 0.5, '武')
    else:
        plt.text(0.4, 0.5, shen)

gong4 = plt.subplot(gs[0, 0])  
plt.title("巽四宫")
paipan('巽')
if dipan == '壬' or tianpan == '壬':
    plt.text(0.1, 0.6, '壬六击')
if dipan == '癸' or tianpan == '癸':
    plt.text(0.05, 0.3, '癸六击')  


gong3 = plt.subplot(gs[1, 0])
plt.xlabel("震三宫")
paipan('震')
if dipan == '戊' or tianpan == '戊':
    plt.text(0.05, 0.3, '戊六击')  
if men == '開':
    plt.text(0.5, 0.05, '门迫', fontsize=9, color='green')

gong8 = plt.subplot(gs[2, 0])
plt.xlabel("艮八宫")
paipan('艮')
if dipan == '庚' or tianpan == '庚':
    plt.text(0.1, 0.3, '庚六击')
if dipan == '丁' or tianpan == '丁':
    plt.text(0.65, 0.5, '丁入墓')  
    
gong9 = plt.subplot(gs[0, 1])
plt.title("离九宫")
paipan('離')
if dipan == '辛' or tianpan == '辛':
    plt.text(0.1, 0.3, '辛六击')
    
gong5 = plt.subplot(gs[1, 1])
plt.xticks([])
plt.yticks([])
dipan5 = jihe['地盤']['中']
plt.text(0.85, 0.1, dipan5)


gong1 = plt.subplot(gs[2, 1])
plt.xlabel("坎一宫")
paipan('坎')
if men == '死' or men == '生':
    plt.text(0.5, 0.05, '门迫', fontsize=9, color='green')

gong2 = plt.subplot(gs[0, 2])
plt.title("坤二宫")
paipan('坤')
#六仪击刑
if dipan == '己' or tianpan == '己':
    plt.text(0.1, 0.3, '己六击')
#入墓
if dipan == '癸' or tianpan == '癸':
    plt.text(0.65, 0.5, '癸入墓')  
if dipan == '乙' or tianpan == '乙':
    plt.text(0.65, 0.5, '乙入墓')  
#门迫
if men == '傷':
    plt.text(0.5, 0.05, '门迫', fontsize=9, color='green')

gong7 = plt.subplot(gs[1, 2])
plt.xlabel("兑七宫")
paipan('兌')

gong6 = plt.subplot(gs[2, 2])
plt.xlabel("乾六宫")
paipan('乾')
if dipan == '丙' or tianpan == '丙':
    plt.text(0.65, 0.5, '丙入墓')  
if men == '景':
    plt.text(0.5, 0.05, '门迫', fontsize=9, color='green')
    
plt.savefig('test', dpi=1200)
plt.show()

  今天把天禽星、天芮星搞定了,但是天干还是存在问题