Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- #Lineplot for every row
- transposed_df_liabilities = balance_df_liabilities.T
- transposed_df_liabilities_percentage = transposed_df_liabilities.div(transposed_df_liabilities.sum(axis=1).replace(0, 1), axis=0) * 100
- transposed_df_liabilities_percentage
- transposed_df_liabilities.plot(subplots= True, figsize=(10,12), sharex= False, sharey=False)
- # OR in percentage
- ax = transposed_df_liabilities_percentage.plot(kind='line', subplots=True,figsize=(10,12), sharex= False, sharey=False, layout=(len(transposed_df_liabilities_percentage.columns), 1), legend=True)
- for subplot in ax:
- for a in subplot:
- a.yaxis.set_major_formatter(mtick.PercentFormatter(xmax =100))
- plt.tight_layout() # Adjusts plot spacing
- plt.show()
- #Histograms with two different columns
- plt.figure(figsize = (20,25))
- sns.set(font_scale=2.5)
- fig, ax = plt.subplots()
- ax.bar(month_quantity_2017['TransactionDate'], month_quantity_2017['Quantity'])
- # How to set the size
- sns.set(font_scale=8.7)
- fig, ax = plt.subplots(figsize=(80, 40))
- ax.bar(category_quantity_2017['ACM Application L2 Ver2'], category_quantity_2017['Quantity'])
- plt.xlabel('Product Category')
- plt.xticks(rotation=90)
- plt.ylabel('Quantity')
- plt.title('Sold Quantity from each category (ACM Application L2 Ver2) in 2017')
- plt.show()
- #########################################################
- df_diesel["bins"] = pd.cut(df_diesel['Price BGN'], [0,5000,10000,15000,20000,2000000])
- ax = df_diesel["bins"].value_counts(normalize=True).plot.bar()
- ax.bar_label(ax.containers[0], label_type='edge')
- plt.xlabel('Price BGN')
- plt.ylabel('Percentages')
- plt.title("Diesel engines: Price Distribution")
- plt.show()
- #####################################################
- # Count plot
- plt.figure(figsize=(12,8))
- df_actors_last.Actor.value_counts().head(20).plot(kind = 'bar', fontsize = 15)
- plt.show()
- df.sort_values(by=['age'])
- plt.figure(figsize=(20,15), dpi = 200)
- sns.countplot(data = df.sort_values(by=['age']), x = 'age', palette = 'magma' )
- plt.show()
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.1, palette="viridis")
- sns.countplot(data = listings.loc[listings.IPO_Year > 2000], x = "IPO_Year", hue = "Exchange")
- plt.legend(loc= "upper left")
- plt.savefig("list_countpl")
- ####################################################
- sns.set(rc={'figure.figsize':(10.7,8.7)})
- plt.xticks(rotation=90)
- sns.set(style='darkgrid')
- plt.figure(figsize=(10,5), dpi = 200)
- sns.histplot(data=df, x = 'age', color = 'blue', linewidth = 2)
- plt.show()
- #####################################################
- plt.style.available
- plt.style.use("seaborn) # how to choose the style
- ######################################################
- titanic.age.hist(figsize(12,8), bins=80, xlabelsize=15, ylabelsize=15)
- plt.show()
- ######################################################
- # Create histogram
- sns.set(style='darkgrid')
- plt.figure(figsize=(5,8), dpi = 200)
- distribution = sns.histplot(data=df, x = 'salary', bins = 10, color = 'red', edgecolor = 'blue', linewidth = 4, kde = True)
- print(distribution)
- ################################################## How to plot value counts
- plt.figure(figsize=(20,12))
- fandago['YEAR'].value_counts().plot(kind='barh')
- plt.show()
- ##################################################
- plt.figure(figsize=(20,15), dpi = 200)
- sns.countplot(data = fandago, x = 'STARS_DIFF', palette = 'magma' )
- plt.title('Number of times a difference occurs')
- plt.show()
- ##################################################
- xticks = [x for x in range(0,901, 50)]
- yticks = [y for y in range(0, 81, 5)]
- plt.style.use("classic")
- titanic.age.plot(figsize = (12,8), fontsize= 13, c = "r", linestyle = "-",
- xlim = (0,900), ylim = (0,80), xticks = xticks, yticks = yticks, rot = 45)
- plt.title("Titanic - Ages", fontsize = 15)
- plt.legend(loc = 3, fontsize = 15)
- plt.xlabel("Passenger No", fontsize = 13)
- plt.ylabel("Age", fontsize = 13)
- #plt.grid()
- plt.show()
- #########################################################
- plt.style.use("ggplot")
- plt.figure(figsize=(12, 8))
- plt.bar(df_converted['Year'], df_converted['Dividends'], color = 'b' )
- plt.xlabel('Year')
- plt.ylabel('Total Dividends')
- plt.title('Dividends by Year')
- plt.show()
- plt.figure(figsize=(12,8))
- sns.set(font_scale=1.0)
- sns.barplot(data = listings , x = 'Exchange', y = "Market_Cap", dodge = True)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement