<jupyter_start><jupyter_text>Plot of Sin(x) + Sin(y)<jupyter_code>points = np.arange(-5,5,.01)
dx,dy = np.meshgrid(points,points)
z = (np.sin(dx)+np.sin(dy))
plt.imshow(z)
plt.colorbar()
plt.title('Plot of sin(x)+sinx(y)')<jupyter_output><empty_output><jupyter_text>Plot For Histogram<jupyter_code>d1 = np.random.randn(100)

plt.hist(d1)
d2 = np.random.randn(80)

plt.hist(d2, color = 'indianred')
plt.hist(d1, density =True, color ='indianred', bins=20, alpha =0.5)
plt.hist(d2, density= True, bins = 20, alpha =0.5)

#density is to make both plots fit in one area. aplha is for transparency<jupyter_output><empty_output><jupyter_text>Trying the same using seaborn<jupyter_code>data1 = np.random.randn(1000)
data2 = np.random.randn(1000)

sns.jointplot(data1,data2)
#basic joint plot
sns.jointplot(data1,data2, kind = 'hex')
#Speciifying the kind of plot<jupyter_output><empty_output><jupyter_text>Combining Plot Styles<jupyter_code>data = np.random.randn(1000)
sns.distplot(data)
# combines kde with histogram
sns.distplot(data, bins =25, rug = True, hist = False )

# Kde with rug and no histogram
sns.distplot(data, bins = 25, 
             kde_kws= {'color': 'indianred', 'label': 'KDE Plot'},
             hist_kws = {'color': 'blue', 'label': 'HIST Plot'})
# declaring attributes as dictionaries<jupyter_output><empty_output><jupyter_text>Box and Violin Plots<jupyter_code>data1 = np.random.randn(100)
data2 = np.random.randn(100)

sns.boxplot( data= [data1, data2], orient = 'v')

# Combines kde along with a box plot = hence gives the probablity density specifying bandwidth(bw)
sns.violinplot( data= [data1, data2], orient = 'v', bw =0.5)<jupyter_output><empty_output><jupyter_text>Regression Plots<jupyter_code>tips = sns.load_dataset('tips')
tips.head()
sns.lmplot('total_bill', 'tip', tips)
sns.lmplot('total_bill', 'tip', tips, order= 4,
          scatter_kws = {'marker': 'o', 'color': 'indianred'},
          line_kws = {'linewidth': 2 , 'color': 'black'})

# specifying each attribute using dictionaries and order by the number
sns.lmplot('total_bill', 'tip', tips, fit_reg = False)
tips['tips_pect'] = 100*(tips['tip']/tips['total_bill'])
tips.head()

#To plot percentage of tip against size of the party
sns.lmplot('size', 'tips_pect', tips, x_jitter =.1)
sns.lmplot('total_bill', 'tips_pect', tips, hue ='sex', markers =['x','o'])
#adding markers as column 'sex'
sns.regplot('total_bill', 'tips_pect', tips)
# lower level plot of lmplot - used when it's a part of many plots in a figure
fig , (axis1, axis2) = plt.subplots(1,2,sharey = True)

sns.regplot('total_bill', 'tips_pect', tips, ax = axis1)
sns.violinplot(data = [tips['tips_pect'], tips['size']], color = 'red', ax = axis2)<jupyter_output><empty_output><jupyter_text>Clustered Matrices and Heatmaps<jupyter_code>flight_dframe = sns.load_dataset('flights')
flight_dframe.head()
flight_dframe= flight_dframe.pivot('month','year', 'passengers')
flight_dframe
sns.heatmap(flight_dframe, annot =True, fmt='d', center = flight_dframe.loc['January',1955])
yearly_flights = flight_dframe.sum()

years = pd.Series(yearly_flights.index.values)

years = pd.DataFrame(years)

flights = pd.Series(yearly_flights.values)
flights = pd.DataFrame(flights)


year_dframe = pd.concat((years, flights), axis =1)
year_dframe.columns = ['Year','Flights']
f, (axis1,axis2) = plt.subplots(2,1)

sns.barplot('Year', y ='Flights', data = year_dframe, ax=axis1)
sns.heatmap(flight_dframe, ax=axis2,cmap="YlGnBu")
sns.clustermap(flight_dframe, cmap="YlGnBu")
sns.clustermap(flight_dframe, cmap="YlGnBu", col_cluster=False, standard_scale =1)
# clsutering only by rows and standardizing by column 
sns.clustermap(flight_dframe, cmap="YlGnBu", col_cluster=False, standard_scale =0)
# clsutering only by rows and standardizing by rows
sns.clustermap(flight_dframe, z_score =1)

#standardizing by z score<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15352910870685213, 'fraction_numerical': 0.021895929933024215, 'mean_word_length': 6.467307692307692, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '342103', 'license': 'MIT', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1509, 'n_words': 325, 'path': 'Basics Of Visualization Using MatPlotLib and Seaborn.ipynb', 'repo_name': 'TruptiJayakumar/BasicsOfVisualizationUsingMatplotlibandSeaborn', 'size': '3882'}