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/19 14:57] Beretta, Anna Letizia |
python:first_course_statistics [2016/10/26 19:34] Beretta, Anna Letizia |
||
---|---|---|---|
Ligne 134: | Ligne 134: | ||
plt.show() | plt.show() | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | \\ | ||
+ | |||
+ | =====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> | ||
+ | |||
+ | |||
+ | =====Scatterplot (p. 17)===== | ||
+ | <code python> | ||
+ | import matplotlib.pyplot as plt | ||
+ | import pandas as pd | ||
+ | adoption_scatterplot = pd.read_csv('...\adopt.TAB', '\t') | ||
+ | adopt_data_Xax = adoption_scatterplot['Visa88'] | ||
+ | adopt_data_Yax = adoption_scatterplot['Visa91'] | ||
+ | plt.scatter(adopt_data_Xax, adopt_data_Yax, facecolor='y', edgecolor='y') | ||
+ | ax = plt.gca() | ||
+ | ax.set_xlabel('Number of Visas in 1988') | ||
+ | ax.set_ylim([0,2700]) | ||
+ | ax.set_xlim([0,5000]) | ||
+ | ax.set_ylabel('Number of Visas in 1991') | ||
+ | ax.set_title('ScatterPlot of Visa91 vs Visa88') | ||
+ | plt.show() | ||
+ | </code> | ||
+ | |||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | =====Scatterplot (p.18)===== | ||
+ | <code python> | ||
+ | import matplotlib.pyplot as plt | ||
+ | import pandas as pd | ||
+ | adoption_scatterplot = pd.read_csv('D:\Python\Libri\A_Casebook_for_a_First_Course_in_Statistics_and_Data_Analysis_Datasets\Data\Tab\\adopt.TAB', '\t') | ||
+ | adopt_data_Xax = adoption_scatterplot['Visa91'] | ||
+ | adopt_data_Yax = adoption_scatterplot['Visa92'] | ||
+ | plt.scatter(adopt_data_Xax, adopt_data_Yax, facecolor='y', edgecolor='y') | ||
+ | ax = plt.gca() | ||
+ | ax.set_xlabel('Number of Visas in 1991') | ||
+ | ax.set_ylim([0,1800]) | ||
+ | ax.set_xlim([0,2700]) | ||
+ | ax.set_ylabel('Number of Visas in 1992') | ||
+ | ax.set_title('ScatterPlot of Visa92 vs Visa91') | ||
+ | plt.show() | ||
+ | </code> | ||
+ | |||
+ |