salleynealt / codecademy-dvp-2

Data Visualization with Python
0 stars 0 forks source link

Netflix Visualizations - Beautiful Second Graph and a Bit of Refactored Code #4

Open jmcrey opened 6 years ago

jmcrey commented 6 years ago
x_positions = [1, 2, 3, 4]
chart_labels = ["1Q2017","2Q2017","3Q2017","4Q2017"]
chart_label2 = ["First","Second","Third","Fourth"]
earnings_actual =[.4, .15,.29,.41]
earnings_estimate = [.37,.15,.32,.41 ]
plt.scatter(x_positions, earnings_actual, color = "red",alpha=0.7, marker = "1")
plt.scatter(x_positions, earnings_estimate, color = "blue",alpha=0.7, marker = "2")
plt.xticks(x_positions, chart_label2)
plt.title("Netflix Earnings Per Share In Cents")
plt.ylabel("EPS Ratio")
plt.xlabel("Business Quarters in 2017")
plt.legend(["Actual", "Estimate"])
plt.savefig("chart2.png")

This second graph is lovely. Great use of color, great use of a custom market, and nice labels on the x and y axis. The outcome of the graph is astounding! Also, I love the way the code reads -- it is super clear, especially that everything is declared first and then used as the code progresses. It gives it a nice flow. My one little nit picky thing is that it is a best practice to put a spaced after commas in Python. Also, it is common to not use a space when giving a parameter a value in a function. Here is an example of what I mean:

Before:

earnings_actual =[.4, .15,.29,.41]
earnings_estimate = [.37,.15,.32,.41 ]
plt.scatter(x_positions, earnings_estimate, color = "blue",alpha=0.7, marker = "2")

After:

earnings_actual =[.4, .15, .29, .41]
earnings_estimate = [.37, .15, .32, .41]
plt.scatter(x_positions, earnings_estimate, color="blue", alpha=0.7, marker="2")`

It just makes the code a bit easier to distinguish. But, this is not too much of a big deal (and some even think it's personal preference). Just a small tip!

But again, beautiful second graph. It really is very nice.