2

I have a pandas dataframe like following:

Category X_Axis Y_Axis
Categor1 10000 10000
Categor2 15000 20000
Categor3 20000 30000
Categor1 25000 40000
Categor2 10000 50000

I want my code to create a scatter plot with X_Axis values on horizontal, and Y_Axis on vertical, and colors showing the categories, with every category having a different color and a legend showing them.

I cannot do this manually because of the size of the data and having a lot of different categories.

Thanks in advance.

0

1 Answer 1

1

If you can use seaborn:

import seaborn as sns

sns.scatterplot('X_Axis','Y_Axis',hue='Category',data=df)

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.