janboone / applied-economics

course material for the course applied economics
17 stars 21 forks source link

Questions code #21

Closed RuxCoj closed 4 years ago

RuxCoj commented 4 years ago
  1. I noticed that whether or not we use the code "plt.show()", the plots, scatterplots, histograms still appear. Is there a point in using this line of code?
  2. I didn't understand what the command "plt.clf()" does. It is supposed to clear out the previous plot so you can start afresh. But it seems like creating multiple plots one after the other works anyway. What is the a point to this command?
  3. The following code should work for making a plot according to Datacamp, but it doesn't: "plt.plot(cars) plt.show()" . cars is a dataframe. It returns an empty plot.
  4. So does the following code for making a plot: "plt.yscale('log') plt.show()"
  5. This didn't work to save: cars['population'].plot(color='b', style='.-', legend=True) plt.axis((0, 6, 500, 6000)) plt.savefig('C:/Users/Mihaela/Desktop/Economic Analysis/cars.jpg') plt.show()

Why?

janboone commented 4 years ago

thanks a lot; we will discuss this tomorrow.

On point 5: I assume that you tried to run this code on the jupyterlab server of the TiU?