Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # %%
- import matplotlib.pyplot as plt
- import seaborn as sns
- import numpy as np
- # %%
- yield_apples =[0.895, 0.91, 0.919, 0.926, 0.929, 0.931]
- plt.plot(yield_apples)
- # %%
- years = [2010, 2011, 2012, 2013, 2014, 2015]
- yield_apples =[0.895, 0.91, 0.919, 0.926, 0.929, 0.931]
- # %%
- plt.plot(years,yield_apples)
- plt.xlabel('years')
- plt.ylabel('Yield (Tons per hectere)')
- # %%
- years = range(2000, 2012)
- apples = [0.895, 0.91, 0.919, 0.929, 0.931, 0.934, 0.936, 0.937, 0.9375, 0.9372, 0.939, 0.940]
- oranges = [0.962, 0.941, 0.930, 0.923, 0.918, 0.908, 0.907, 0.904, 0.901, 0.898, 0.9, 0.896]
- # %%
- sns.set_style("whitegrid")
- plt.plot(years, apples, label='Apples', marker = 'o')
- plt.plot(years, oranges, label='Oranges', marker = 'x')
- plt.xlabel('Year')
- plt.ylabel('Yield')
- plt.title('Yield of Apples and Oranges (2000-2011)')
- plt.legend()
- plt.show()
- # %%
- sns.set_style("whitegrid")
- plt.figure(figsize=(12,6))
- plt.plot(years,oranges,marker = 'o')
- plt.title("Yeild of Ornages")
- # %%
- years = range(2000,2006)
- apples = [0.35,0.6,0.9,0.8,0.65,0.8]
- oranges = [0.4,0.8,0.9,0.7,0.6,0.8]
- # %%
- sns.set_style("whitegrid")
- plt.bar(years,oranges)
- plt.xlabel('Year')
- plt.ylabel('Yield')
- plt.title("Crop Yield")
- # %%
- sns.set_style("whitegrid")
- plt.bar(years,oranges)
- plt.bar(years,apples, bottom=oranges)
- plt.xlabel('Year')
- plt.ylabel('Yield')
- plt.title("Crop Yield")
- # %%
- tips_df = sns.load_dataset("tips")
- tips_df
- # %%
- sns.barplot(x='day',y='total_bill', data=tips_df)
- # %%
- sns.barplot(x='day',y='total_bill',hue='sex', data=tips_df)
- # %%
- sns.barplot(x='total_bill',y='day',hue='sex', data=tips_df)
- # %%
- flower_df = sns.load_dataset("iris")
- flower_df.sepal_width
- # %%
- plt.title('Distribution of Sepal width')
- plt.hist(flower_df.sepal_width)
- # %%
- plt.hist(flower_df.sepal_width, bins=5)
- # %%
- setosa_df = flower_df[flower_df.species == 'setosa']
- versicolor_df = flower_df[flower_df.species == 'versicolor']
- virginica_df = flower_df[flower_df.species == 'virginica']
- # %%
- plt.hist(setosa_df.sepal_width, alpha=0.4, bins=np.arange(2, 5, 0.25), label='Setosa')
- plt.hist(versicolor_df.sepal_width, alpha=0.4, bins=np.arange(2, 5, 0.25), label='Versicolor')
- # %%
- plt.title('Distribution of Sepal width')
- plt.hist([setosa_df.sepal_width, versicolor_df.sepal_width, virginica_df.sepal_width],
- bins=np.arange(2,5,0.25),
- stacked=True)
- plt.legend(['Setosa','Versicolor','Virginica'])
Advertisement
Advertisement