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
# taken from Coursera.org | |
%matplotlib notebook | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
linear_data = np.array([1,2,3,4,5,6,7,8]) | |
exponential_data = linear_data**2 |
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
# Modified from Coursera.org | |
%matplotlib notebook | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
linear_data = np.array([1,2,3,4,5,6,7,8]) | |
exponential_data = linear_data**2 |
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
# adjust the x-axis labels | |
# step 1: get the x-axis instance. | |
# we can do various things on x-axis instance such as axis.get_ticklabels. | |
# explore other things that we can do on x-axis: https://matplotlib.org/devdocs/api/axis_api.html | |
ax = plt.gca().get_xaxis() | |
# ax2 = plt.gca().xaxis | |
# print(ax) | |
# print(ax2) | |
# step 2: get the ticklabels of the Xaxix |
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
# create a multiseries bar chart | |
# make multiple calls on 'plt.bar()' | |
# series 1 | |
plt.figure() | |
xvals = range(len(linear_data)) | |
plt.bar(xvals, linear_data, width = 0.3) | |
#series 2: | |
new_xvals = [] |
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
from random import randint | |
plt.figure() | |
xvals = range(len(linear_data)) | |
plt.bar(xvals, linear_data, width = 0.3) | |
linear_err = [randint(0,5) for x in range(len(linear_data))] | |
print(linear_err) | |
# This will plot a new set of bars with errorbars using the list of random error values |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
plt.figure() | |
languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript'] | |
pos = np.arange(len(languages)) | |
popularity = [56, 39, 34, 34, 29] | |
plt.bar(pos, popularity, align='center') |
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
import matplotlib.pyplot as plt | |
import numpy as np | |
plt.figure() | |
languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript'] | |
pos = np.arange(len(languages)) | |
popularity = [56, 39, 34, 34, 29] | |
# change the bar colors to be less bright blue |
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
# 100% taken from coursera | |
import matplotlib.pyplot as plt | |
import numpy as np | |
plt.figure() | |
languages =['Python', 'SQL', 'Java', 'C++', 'JavaScript'] | |
pos = np.arange(len(languages)) | |
popularity = [56, 39, 34, 34, 29] |
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
import matplotlib.pyplot as plt | |
import matplotlib.patches as patches | |
# build a rectangle in axes coords | |
left, width = .25, .5 | |
bottom, height = .25, .5 | |
right = left + width | |
top = bottom + height | |
fig = plt.figure() |
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
#taken from https://matplotlib.org/users/text_props.html | |
import matplotlib.pyplot as plt | |
import matplotlib.patches as patches | |
# build a rectangle in axes coords | |
left, width = .25, .5 | |
bottom, height = .25, .5 | |
right = left + width | |
top = bottom + height |