0
import matplotlib.pyplot as plt
plt.figure(figsize=(20,10))

plt.plot(norway.Freedom, norway.Economy_GDP_per_Capita, color = 'navy', label = 'Norway')

plt.legend(loc = 'upper left')
plt.title('Effect of GDP against Freedom')
plt.xlabel('Freedom')
plt.ylabel('GDP')

plt.show()

Example row in the data: Data Frame

Output: Graph

I make a quick start to Data Science and I am trying to make some analysis on Kaggle. I write a kernel for plotting a line as you see in my code, although the graph is empty and I can not see anything. Besides that, there is no error or something. I need help with it. Please try to explain without going deep, I am a beginner. Thanks everybody who will help.

I am not sure whether you guys can see my code and graph...

1 Answers1

1

It's just because your dataframe has only one single row, therefore both norway.Freedom and norway.Economy_GDP_per_Capita are just single numbers so you are trying to plot one single point. If you try to plot this without markers, you'll see nothing. Try

plt.plot(norway.Freedom, norway.Economy_GDP_per_Capita, 'x', color = 'navy', label = 'Norway')

which adds x-markers to the plot.

Or choose a dataframe with more than one row of data...

SpghttCd
  • 10,510
  • 2
  • 20
  • 25