Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
python:first_course_statistics [2016/10/24 14:30] Beretta, Anna Letizia [Scatterplot (p.18)] |
python:first_course_statistics [2016/10/28 11:54] Beretta, Anna Letizia |
||
---|---|---|---|
Ligne 137: | Ligne 137: | ||
\\ | \\ | ||
+ | |||
+ | =====Histogram with Log(p.18)===== | ||
+ | don't find the way to do it | ||
+ | <code Python> | ||
+ | import pandas as pd | ||
+ | import matplotlib.pyplot as plt | ||
+ | adopt = pd.DataFrame(pd.read_csv('D:\Python\Libri\A_Casebook_for_a_First_Course_in_Statistics_and_Data_Analysis_Datasets\Data\Tab\\adopt.TAB', '\t')) | ||
+ | adopt_loghist = adopt['Visa91'] | ||
+ | #adopt_loghist.semilogx() --> was one of the possibilities | ||
+ | ax = plt.gca() | ||
+ | ax.hist(adopt_loghist, bins=10, plt.loglog(0.5,3.5), color='r') #put log=True instead, but you will get the log for the frequencies | ||
+ | plt.gca().set_xscale("log") | ||
+ | ax.set_xlabel('Log (Number of 1991 visas') | ||
+ | ax.set_ylabel('Frequency') | ||
+ | ax.set_title('Histogram') | ||
+ | plt.show() | ||
+ | </code> | ||
Ligne 177: | Ligne 194: | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | ===== Scatterplot of Productivity vs Quality (p. 26) ===== | ||
+ | <code Python> | ||
+ | import pandas as pd | ||
+ | import matplotlib.pyplot as plt | ||
+ | scatter_plot = pd.read_csv('D:\Python\Libri\A_Casebook_for_a_First_Course_in_Statistics_and_Data_Analysis_Datasets\Data\Tab\\prdq.TAB', '\t') | ||
+ | productivity_Y = scatter_plot['Producti'] | ||
+ | quality_X = scatter_plot['Quality'] | ||
+ | plt.scatter(productivity_Y, quality_X, bins=20, colors='r') | ||
+ | ax = plt.gca() | ||
+ | ax.set_Xlabel('Assembly defects per 100 cars') | ||
+ | ax.set_Ylabel('Hours per vehicle') | ||
+ | ax.set_title('Scatter Plot of Productivity VS Quality') | ||
+ | plt.show() | ||
+ | </code> | ||