import numpy as np
from sympy import *
import matplotlib.pyplot as plt
from IPython.display import display
import japanize_matplotlib

def descartes(ax, ran_x, ran_y, ax_title,x_label = "x", y_label = "y"):
    ax.set_xlabel(x_label, fontsize = 12)
    ax.set_ylabel(y_label, fontsize = 12)
    ax.set_xlim(ran_x[0], ran_x[1])
    ax.set_ylim(ran_y[0], ran_y[1])
    ax.set_title(ax_title, fontsize = 14)
    ax.grid()
    ax.axhline(0, color = "black")
    ax.axvline(0, color = "black")


fig = plt.figure(figsize = (5, 5))
ax = fig.add_subplot(111)


title1 = "数学Ⅲ 複素数平面 練習4"
x_label = "実軸"
y_label = "虚軸"
descartes(ax, [-3,3], [-3, 3],title1,x_label,y_label)
from sympy import *

z = Symbol('z',complex=True)
z1,z2 = symbols('z1:3',complex=True)
f = z1**6-1
print(f) 
z2=solve(f,z1)
print(z2)
i=0
for z in z2:
    i += 1
    ax.scatter(re(z) ,im(z) , color = "blue")
    ax.text(re(z)-0.2,im(z)+0.1,"Z{}".format(i))
    ax.text(-2.2,-1.3-0.25*i,"Z{}:{}".format(i,z))

plt.show()