Skip to content

Instantly share code, notes, and snippets.

View AmirMardan's full-sized avatar

Amir Mardan AmirMardan

View GitHub Profile
@AmirMardan
AmirMardan / adb121f2-267b-4bc4-97d8-967bf5ddefa5.py
Created March 21, 2022 05:02
different_plots_in_matplotlib27
# Let's generate some data
spread = np.random.rand(50) * 100
center = np.ones(25) * 50
flier_high = np.random.rand(10) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low))
@AmirMardan
AmirMardan / 27c85bfc-d867-428f-8940-fc24590cc0d4.py
Created March 21, 2022 05:02
different_plots_in_matplotlib26
Q1-1.5IQR Q1 median Q3 Q3+1.5IQR
|-----:-----|
o |--------| : |--------| o o
|-----:-----|
outlier <-----------> outliers
IQR
@AmirMardan
AmirMardan / 023917dd-a7c3-4a93-aa79-7d056a43259b.py
Created March 21, 2022 05:02
different_plots_in_matplotlib25
fig = plt.figure(figsize=(3, 3))
ax= fig.add_subplot(111)
ax.pie(ordered, labels=days,
shadow=True, # put shadow for plot
radius=1.1, # Radius of the pie
autopct='%.1f',
wedgeprops=dict(width=0.8, # Width of the wedge
edgecolor='#062C30', # color of edge
linewidth= 2 # Thickness of edge
@AmirMardan
AmirMardan / 8ceb966e-b6ad-475e-821a-047dc17d0acb.py
Created March 21, 2022 05:02
different_plots_in_matplotlib24
# A simple pie chart
fig = plt.figure(figsize=(3, 3))
ax= fig.add_subplot(111)
ax.pie(ordered, labels=days);
@AmirMardan
AmirMardan / 5f047c53-b902-4f95-9fc3-5758e9db0b43.py
Created March 21, 2022 05:02
different_plots_in_matplotlib23
# Generate data
mean = [0, 0]
cov = [[1, 1], [1, 2]]
x_hsit2d, y_hsit2d = np.random.multivariate_normal(mean, cov, 10000).T
fig = plt.figure(figsize=(12, 3))
ax= fig.add_subplot(131)
ax.hist(x=x_hsit2d)
@AmirMardan
AmirMardan / c7fe1851-aedd-4a12-9b86-43679423159c.py
Created March 21, 2022 05:02
different_plots_in_matplotlib22
fig = plt.figure(figsize=(5, 3))
# Instead of seperating the number of rows, cols nad plot number, we can put them without seperator
ax= fig.add_subplot(221)
ax.hist([random_letter1, random_letter2],
color=['#39AEA9', '#F1E1A6'], # Color of face
edgecolor='#062C30', # Color of edge
orientation='vertical', # Vertical plot
bins=range(5), # equal-width bins
histtype='bar',
@AmirMardan
AmirMardan / d187586a-11b9-406d-88bd-ea7e5872b56f.py
Created March 21, 2022 05:02
different_plots_in_matplotlib21
fig = plt.figure(figsize=(3, 3))
# Instead of seperating the number of rows, cols nad plot number, we can put them without seperator
ax= fig.add_subplot(111)
ax.hist(random_letter1,
color='#39AEA9', # Color of face
edgecolor='#062C30', # Color of edge
orientation='horizontal', # Horizontal plot
bins=range(5), # equal-width bins
@AmirMardan
AmirMardan / 0045859f-037c-4864-a695-f79fb0a34693.py
Created March 21, 2022 05:02
different_plots_in_matplotlib20
# Simple histogram
fig = plt.figure(figsize=(3, 3))
# Instead of seperating the number of rows, cols nad plot number, we can put them without seperator
ax= fig.add_subplot(111)
# A simple bar plot
plt.hist(random_letter1);
@AmirMardan
AmirMardan / ad22b1df-6f07-450a-b86a-444b6a053a34.py
Created March 21, 2022 05:02
different_plots_in_matplotlib19
fig = plt.figure(figsize=(4, 4))
ax= fig.add_subplot(111)
im = ax.bar(x=days,
height=ordered, # Numeric variable
width=0.5, # Width of bars
color='#39AEA9', # Color of face
edgecolor='#062C30', # Color of edge
alpha=.9, # Make the bars transparent
yerr=error # Show the error along y-axis
@AmirMardan
AmirMardan / 290d9164-3756-4358-ae60-bcbdcaa7f590.py
Created March 21, 2022 05:02
different_plots_in_matplotlib18
fig = plt.figure(figsize=(4, 4))
# Instead of seperating the number of rows, cols nad plot number, we can put them without seperator
ax= fig.add_subplot(111)
# A simple bar plot
ax.bar(x=days, # Categorical variable
height=ordered # Numeric variable
)