This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.figure(figsize=(8, 5), # size | |
dpi=200, # dpi | |
facecolor='yellow' # color of background | |
) | |
plt.plot(x1, y1) | |