#๐Ÿ”’ UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored

9 messages ยท Page 1 of 1 (latest)

rich onyx
#

im using PCA and im plotting my first and second principle components but when i put it into plt.scatter this warning pops up
Here is the code

cancer_df = pd.DataFrame(cancer['data'], columns=cancer['feature_names'])
scaler = StandardScaler()
scaler.fit(cancer_df)
scaled_data = scaler.transform(cancer_df)
pca = PCA(n_components=2)
pca.fit(scaled_data)
x_pca = pca.transform(scaled_data)
plt.figure(figsize=(8, 6))
plt.scatter(x_pca[:, 0], x_pca[:, 1], cmap='plasma')
plt.xlabel('First Principle Component')
plt.ylabel('Second Principle Component')
plt.show()```
young lodgeBOT
#

@rich onyx

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

rich onyx
#

also this is the figure im given

#

and i need it to correctly color the components

oblique pecan
rich onyx
#

Thanks

young lodgeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.