MkvBrk
MkvBrk

Reputation: 23

Scatter plot is not sort in matplotlib from csv file

My Code:

import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("linear_regression_dataset.csv", sep=";")

plt.scatter(df.Deneyim,df.Maas)

plt.xlabel("deneyim")

plt.ylabel("maas")

plt.show()

result image :

Is there a solution proposal?

The graphic I want: That's the graphic I want to be image:

Upvotes: 0

Views: 310

Answers (1)

Venkatachalam
Venkatachalam

Reputation: 16966

sort the dataframe first and then you can plot

import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("linear_regression_dataset.csv", sep=";")
df['Mass']= df['Mass'].astype(int)
df.sort_values('Maas',inplace=True)
plt.scatter(df.Deneyim,df.Maas)

plt.xlabel("deneyim")

plt.ylabel("maas")

plt.show()

Upvotes: 1

Related Questions