奇門遁甲九宮八卦圖


# -*- 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'

from qimen2 import *
y = int(input("請輸入年份: "))
m = int(input("請輸入月份: "))
d = int(input("請輸入日期: "))
h = int(input("請輸入時間(24小時制):"))
print(Qimen(y,m,d,h).p)
jihe = Qimen(y,m,d,h).p

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, '癸六擊')  
if dipan == '辛' or tianpan == '辛':
    plt.text(0.65, 0.5, '辛入墓')
if dipan == '壬' or tianpan == '壬':
    plt.text(0.65, 0.7, '壬入墓')
#門迫
if men == '驚' or men == '開':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')

gong3 = plt.subplot(gs[1, 0])
plt.xlabel("震三宮", fontsize=8)
paipan('震')
if dipan == '戊' or tianpan == '戊':
    plt.text(0.05, 0.3, '戊六擊')  

#門迫
if men == '驚' or 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.05, 0.3, '庚六擊')
if dipan == '庚' or tianpan == '庚':
    plt.text(0.65, 0.7, '庚入墓')
if dipan == '丁' or tianpan == '丁':
    plt.text(0.65, 0.5, '丁入墓')
if dipan == '己' or tianpan == '己':
    plt.text(0.65, 0.5, '己入墓')  
if men == '杜' or men == '傷':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')
    
gong9 = plt.subplot(gs[0, 1])
plt.title("離九宮")
paipan('離')
if dipan == '辛' or tianpan == '辛':
    plt.text(0.05, 0.3, '辛六擊')
if men == '休':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')

    
gong5 = plt.subplot(gs[1, 1])
plt.xticks([])
plt.yticks([])
plt.xlabel(jihe['排局'][0:4], fontsize=8)
plt.text(0.35,0.8, jihe['干支'][0:3])
plt.text(0.35,0.6, jihe['干支'][3:6])
plt.text(0.35,0.4, jihe['干支'][6:9], color='red')
plt.text(0.35,0.2, jihe['干支'][9:], color='red')
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.05, 0.3, '己六擊')
#入墓
if dipan == '癸' or tianpan == '癸':
    plt.text(0.65, 0.7, '癸入墓')  
if dipan == '乙' or tianpan == '乙':
    plt.text(0.65, 0.5, '乙入墓')  
#門迫
if men == '杜' or men == '傷':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')

gong7 = plt.subplot(gs[1, 2])
plt.xlabel("兌七宮", fontsize=8)
paipan('兌')
if men == '景':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')

gong6 = plt.subplot(gs[2, 2])
plt.xlabel("乾六宮")
paipan('乾')
if dipan == '丙' or tianpan == '丙':
    plt.text(0.65, 0.5, '丙入墓')  
if dipan == '戊' or tianpan == '戊':
    plt.text(0.65, 0.6, '戊入墓')  
if dipan == '乙' or tianpan == '乙':
    plt.text(0.65, 0.7, '乙入墓')  
if men == '景':
    plt.text(0.5, 0.05, '門迫', fontsize=9, color='green')
if jihe['旬空']['時空'] == '戌亥':
    plt.text(0.65, 0.8, '空亡', color='red')  
if jihe['馬星']['驛馬'] == '亥':
    plt.text(0.85, 0.8, '馬', color='blue')  
    
#plt.savefig('test', dpi=1200)
plt.show()

  

  效果如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM