In [5]:
def plot_triangle(X,kind):
    n1 = np.array([1,0,0])
    n2 = np.array([0,1,0])
    n3 = np.array([0,0,1])
    n12 = (n1 + n2) / 2
    m1 = np.array([1,-1,0])
    m2 = n3 - n12
    m1 = m1 / np.linalg.norm(m1)
    m2 = m2 / np.linalg.norm(m2)
    
    X1 = (X-n12).dot(m1)
    X2 = (X-n12).dot(m2)
    
    g = sns.jointplot(X1,X2, kind = kind, xlim=(-0.8,0.8), ylim=(-0.45,0.9))
    g.ax_joint_axis("equal")
    plt.show()

In [6]:
x1 = np.random.rand(1000,1)
x2 = (1- x1) *np.random.rand(1000,1)
x3 = 1-x1-x2
X0 = np.hstack([x1, x2, x3])
#X1 = X1/X1.sum(axis=1)[:,np.newaxis]
#X0
#합의 확인
#X0.sum(axis=1)

plot_triangle(X0, kind="scatter")



AttributeErrorTraceback (most recent call last)
<ipython-input-6-792071457c95> in <module>()
      8 #X0.sum(axis=1)
      9 
---> 10 plot_triangle(X0, kind="scatter")

<ipython-input-5-6966d9b2a2bf> in plot_triangle(X, kind)
     13 
     14     g = sns.jointplot(X1,X2, kind = kind, xlim=(-0.8,0.8), ylim=(-0.45,0.9))
---> 15     g.ax_joint_axis("equal")
     16     plt.show()

AttributeError: 'JointGrid' object has no attribute 'ax_joint_axis'

In [14]:
mu = [2,3]
cov = [[1, 0], [0, 1]]
rv = sp.stats.multivariate_normal(mu,cov)

xx = np.linspace(0,4,120)
yy = np.linspace(1,5,150)
XX,YY = np.meshgrid(xx,yy)
plt.grid(False)
plt.contourf(XX,YY, rv.pdf(np.dstack([XX,YY])))
plt.axis("equal")
plt.show()



In [ ]: