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
#### MATPLOTLIBRC FORMAT | |
## This is a sample matplotlib configuration file - you can find a copy | |
## of it on your system in | |
## site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
## there, please note that it will be overwritten in your next install. | |
## If you want to keep a permanent local copy that will not be | |
## overwritten, place it in the following location: | |
## unix/linux: | |
## $HOME/.config/matplotlib/matplotlibrc or |
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
""" | |
=================== | |
Anatomy of a figure | |
=================== | |
This figure shows the name of several matplotlib elements composing a figure | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt |
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 numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.special import comb, perm | |
import math | |
def plt_distribution(distribution_data_list, show=False): | |
fig, ax = plt.subplots() | |
xys, figtitle, figname = distribution_data_list |
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 numpy as np | |
import matplotlib.pyplot as plt | |
def area_polygons(n, l): # n: the number of edges in polygons, l: length of edges | |
apothem = l / (2 * np.tan(np.pi / n)) | |
area = apothem * n * l / 2 | |
return area |
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 numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.image as pli | |
image_data = pli.imread("lindan_smash.jpg") | |
I = image_data.copy() | |
def _mirror(image_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
import numpy as np | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(figsize=(5, 4)) | |
x = np.linspace(1, 5, 100) | |
y1 = np.ones(len(x)) | |
y2 = np.ones(len(x)) * 2 | |
y3 = np.ones(len(x)) * 3 | |
y4 = np.ones(len(x)) * 4 |
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 numpy as np | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(3, 2, figsize=(10, 8)) | |
x = np.linspace(1, 2 * np.pi, 100) | |
# y=sin(x) | |
i, j = 0, 0 | |
ax[i][j].plot(x, np.sin(x), 'k-') |
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 numpy as np | |
import matplotlib.pyplot as plt | |
fig, ax = plt.subplots(figsize=(5, 4)) | |
x = np.linspace(1, 5, 100) | |
y1 = np.ones(len(x)) | |
y2 = np.ones(len(x)) * 2 | |
y3 = np.ones(len(x)) * 3 | |
y4 = np.ones(len(x)) * 4 |
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 numpy as np | |
def f(x): | |
return x**3-3 | |
def fdot(x): | |
return 3*x**2 | |
def NewtonMethod(x0,threshold): | |
x_next=x0-f(x0)/fdot(x0) | |
diff_x=np.abs(x_next-x0) | |
x0=x_next |