labels = X.columns n = len(labels) coeff = np.transpose(pca.components_) pc1 = pca.components_[:, 0] pc2 = pca.components_[:, 1] plt.figure(figsize=(8, 8)) for i in range(n): plt.arrow(x=0, y=0, dx=coeff[i, 0], dy=coeff[i, 1], color="#000000", width=0.003, head_width=0.03) plt.text(x=coeff[i, 0] * 1.15, y=coeff[i, 1] * 1.15, s=labels[i], size=13, color="#000000", ha="center", va="center") plt.axis("square") plt.title(f"Wine Quality Dataset PCA Biplot", loc="left", fontdict={"weight": "bold"}, y=1.06) plt.xlabel("Principal Component 1") plt.ylabel("Principal Component 2") plt.xlim(-1, 1) plt.ylim(-1, 1) plt.xticks(np.arange(-1, 1.1, 0.2)) plt.yticks(np.arange(-1, 1.1, 0.2)) plt.axhline(y=0, color="black", linestyle="--") plt.axvline(x=0, color="black", linestyle="--") circle = plt.Circle((0, 0), 0.99, color="gray", fill=False) plt.gca().add_artist(circle) plt.grid() plt.show()