%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([1,2,3,8], [1,4,9,16], marker='x')
#plt.axis([0,5,0,20])
plt.ylabel('OX')
plt.xlabel('OY')
plt.show()
plt.plot([1,2,3,4], [1,4,9,16], '-o') # Check also '-o', '-x'
plt.axis([0,5,0,20])
plt.ylabel('OX')
plt.xlabel('OY')
import numpy as np
f = lambda x: x**2 - 5*x + 6
x = np.linspace(1.0, 4.0, 100, endpoint=True)
plt.plot(x, f(x))
plt.plot(x, [0] * len(x))
plt.plot([2,3], [0,0], 'o', color='red')
from random import randint
dice = 10
def two_dices():
return randint(1,dice) * randint(1, dice) # '+' => '*'
results = [two_dices() for _ in range(100000)]
plt.hist(results, 100, normed=1, alpha=0.75) # 2*dice-1 => 10
plt.show()
import numpy as np
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
plt.title('Rozklad madrosci w populacji')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.show()
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)
ax.set_xlabel('X')
ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z')
ax.set_zlim(-100, 100)
#plt.show()
plt.savefig('figure_xyz.pdf') # pdf, eps, svg