janboone/applied-economics

Questions code

Closed this issue · 1 comments

  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?

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?