Построение диаграммы рассеяния на одном изображении ⇐ Python
Построение диаграммы рассеяния на одном изображении
I am trying to plot my data using scatter plot however i can't seem to get the 3 plots into 1 image How do i solve this:
nu_cluster = 3 kmeans = KMeans(n_clusters=nu_cluster,random_state=0) data_df["cluster"] = kmeans.fit_predict(X_std) print("after Kmeans predict")# visualization plt.figure(figsize=(8, 6)) for i in range(nu_cluster): cluster_data = data_df[data_df["cluster"] == i]#return a boolean and then passed to data_df plt.scatter(cluster_data["charges"], cluster_data["age"],c=[plt.cm.viridis(i / (nu_cluster - 1))] ,label=f"Cluster {i + 1}") plt.xlabel("Charges") plt.ylabel("Age") plt.title("Cluster of age against charges", fontsize=16, fontweight="bold") plt.legend(loc="lower right") plt.show() I tried using the figure() function provided by matplotlib but with no success. plt.figure(figsize=(8,7))
Источник: https://stackoverflow.com/questions/781 ... in-1-image
I am trying to plot my data using scatter plot however i can't seem to get the 3 plots into 1 image How do i solve this:
nu_cluster = 3 kmeans = KMeans(n_clusters=nu_cluster,random_state=0) data_df["cluster"] = kmeans.fit_predict(X_std) print("after Kmeans predict")# visualization plt.figure(figsize=(8, 6)) for i in range(nu_cluster): cluster_data = data_df[data_df["cluster"] == i]#return a boolean and then passed to data_df plt.scatter(cluster_data["charges"], cluster_data["age"],c=[plt.cm.viridis(i / (nu_cluster - 1))] ,label=f"Cluster {i + 1}") plt.xlabel("Charges") plt.ylabel("Age") plt.title("Cluster of age against charges", fontsize=16, fontweight="bold") plt.legend(loc="lower right") plt.show() I tried using the figure() function provided by matplotlib but with no success. plt.figure(figsize=(8,7))
Источник: https://stackoverflow.com/questions/781 ... in-1-image
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение