Skip to content

Instantly share code, notes, and snippets.

View AmirMardan's full-sized avatar

Amir Mardan AmirMardan

View GitHub Profile
@AmirMardan
AmirMardan / 21a2a5fc-8cb0-4b44-86c3-fafeda735071.py
Created March 21, 2022 05:02
different_plots_in_matplotlib17
# Let's create a dataset
days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
ordered = [30, 50, 12, 62, 80]
error = 2 + 3 * np.random.rand(len(days))
@AmirMardan
AmirMardan / 6865399c-fe06-4e6b-b6cd-a2547dabbd3a.py
Created March 21, 2022 05:02
different_plots_in_matplotlib16
with plt.xkcd(): # Activate xkcd plot
fig = plt.figure(figsize=(3, 2))
ax = fig.add_subplot(1, 1, 1)
im = ax.scatter(x = x, # Data along x-direction
y = y, # Data along x-direction
c = category, # Set the color of markers based on an array
s = importance, # Set the size of markers based on an array
)
@AmirMardan
AmirMardan / 7f84fd69-5bf0-44b2-b6cf-bfeb703dc0d7.py
Created March 21, 2022 05:02
different_plots_in_matplotlib15
fig = plt.figure(figsize=(3, 2))
ax = fig.add_subplot(1, 1, 1)
im = ax.scatter(x = x, # Data along x-direction
y = y, # Data along x-direction
c = category, # Set the color of markers based on an array
s = importance, # Set the size of markers based on an array
)
ax.set_xlim([0, 1.7])
@AmirMardan
AmirMardan / 9b5ab3ac-8b57-40ab-a419-45b8f8f3071c.py
Created March 21, 2022 05:02
different_plots_in_matplotlib14
fig = plt.figure(figsize=(3, 2))
ax = fig.add_subplot(1, 1, 1)
im = ax.scatter(x = x, # Data along x-direction
y = y, # Data along x-direction
c = category, # Set the color of markers based on an array
s = importance, # Set the size of markers based on an array
)
ax.set_xlim([0, 1.5])
@AmirMardan
AmirMardan / 182235a1-5038-406c-bb0d-513f05d725bf.py
Created March 21, 2022 05:02
different_plots_in_matplotlib13
fig = plt.figure(figsize=(3, 2))
ax = fig.add_subplot(1, 1, 1)
ax.scatter(x=x, # Data along x-direction
y=y # Data along x-direction
);
@AmirMardan
AmirMardan / 51989019-1176-42c2-9b2e-d073a13c24d2.py
Created March 21, 2022 05:02
different_plots_in_matplotlib12
# Let's generate some data
x = np.random.random((50, 1))
y = np.random.random((50, 1))
category = np.random.choice(5,
50)
importance = 9 + 17 * np.random.random((50, 1))
x_normal = np.random.normal(0, 2, (50, 1))
@AmirMardan
AmirMardan / 93b57b58-431d-4844-9291-f5b5aa4e241b.py
Created March 21, 2022 05:02
different_plots_in_matplotlib11
plt.figure()
plt.plot()
plt.savefig('./img/saved_fig.pdf', # Path to save the file
dpi=600, # Dot per inches
bbox_inches="tight", # To delete the white space around the axes
pad_inches=0.1 # To have a padding
)
@AmirMardan
AmirMardan / cb63edb5-d77e-45dd-aa7c-90355d3ef661.py
Created March 21, 2022 05:02
different_plots_in_matplotlib10
fig = plt.figure(figsize=(3, 2),
dpi=100,
facecolor='yellow'
)
ax1 = fig.add_subplot(1, 1, 1) # adding a subplot to figure object
ax1.plot(x1, y1, 'k') # plot using ax object
ax1.plot(x2, y2, 'k',
alpha=.2 # Alpha is used to create a transparent line
)
@AmirMardan
AmirMardan / a94119bd-ae78-4dab-bddc-5b638f1f37dd.py
Created March 21, 2022 05:02
different_plots_in_matplotlib9
# Let's define a font style for title of plots first
title_fontdic= {'size':9, 'color':'red', 'fontname':'Segoe Print', 'family':'serif'}
# Let's create a figure object
fig = plt.figure(figsize=(5, 2),
dpi=100,
facecolor='yellow'
)
@AmirMardan
AmirMardan / aea96f9e-f3e3-4589-9c4f-f73b3ee698df.py
Created March 21, 2022 05:02
different_plots_in_matplotlib8
plt.figure(figsize=(8, 5), # size
dpi=200, # dpi
facecolor='yellow' # color of background
)
plt.plot(x1, y1)