0

enter image description here So this is how my dataset looks like but when i use

plot.line()

it gives me the error " no numeric data to plot"

apply to numeric doesn't seem to work

1
  • 1
    df.plot('Country Name' , 'China') Commented Nov 18, 2022 at 19:53

2 Answers 2

1

check if the below code helps.

import matplotlib.pyplot as plt
x = df.iloc[:,0]
y = df.iloc[:,1]
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
Sign up to request clarification or add additional context in comments.

5 Comments

it gives errors. it doesn't understand area/colors/alpha and if i delete those parts and only put it in (x, y) it gives me this : ibb.co/xY6P4jf
Okay, i think you can get rid of area/colors/alpha. i am sure your data is very big data that i why the plot is not very precise. You can still see how it works by working with the subset of the data by doing df = df.head(50) now look how your plot is.
alternate way: also you can how your plot looks like by doing df.plot("Country Name", "China")
okay so it seems i used your code on the original data and that's why it looked like that. but when i use it on the dataset that i posted above it gives me "single positional indexer is out-of-bounds" error
import matplotlib.pyplot as plt df = df.head(50) x = df.iloc[:,0] y = df.iloc[:,1] plt.scatter(x, y, s=area, c=colors, alpha=0.5) plt.show() can you try this?
0

There are so, so many ways!

import seaborn as sns

sns.scatterplot(x="Country Name", y="China", data=df)

sns.lineplot(x="Country Name", y="China", data=df)

sns.barplot(x="Country Name", y="China", data=df)

See the links below for more info.

https://www.python-graph-gallery.com/

https://seaborn.pydata.org/tutorial/introduction

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.