Matplotlib

Python pro uživatele R

Daniel Chen

Instructor

Grafy v matplotlib

import matplotlib.pyplot as plt
plt.hist(iris['sepal_length'])
plt.show()

Python pro uživatele R

Bodový graf v matplotlib

plt.scatter(iris['sepal_length'], iris['sepal_width'])
plt.show()

Python pro uživatele R

Úprava grafu

fig, ax = plt.subplots()
ax.scatter(iris['sepal_length'], iris['sepal_width'])
ax.set_title('Sepal Length')
ax.set_xlabel('Sepal Length')
ax.set_ylabel('Sepal Width')
plt.show()

Python pro uživatele R

Otočení popisků osy

fig, ax = plt.subplots()
ax.scatter(iris['sepal_length'], iris['sepal_width'])
ax.set_title('Sepal Length')
ax.set_xlabel('Sepal Length')
ax.set_ylabel('Sepal Width')
plt.xticks(rotation=45) # rotate the x-axis ticks
plt.show()

Python pro uživatele R

Části grafu matplotlib

Python pro uživatele R

Části grafu matplotlib 2

Python pro uživatele R

Obrázky a osy

fig, ax = plt.subplots()
ax.scatter(iris['sepal_length'], iris['sepal_width'])
plt.show()

Python pro uživatele R

Více os

fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.scatter(iris['sepal_length'], iris['sepal_width'])
ax2.hist(iris['sepal_length'])
plt.show()

Python pro uživatele R

Připomenutí

fig, ax = plt.subplots()
sns.regplot(x='sepal_length', y='sepal_width',
            data=iris, fit_reg=False, ax=ax)
plt.show()

plot

Python pro uživatele R

Vymazání grafu

fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.scatter(iris['sepal_length'], iris['sepal_width'])
ax2.hist(iris['sepal_length'])
plt.show()
plt.clf()

Python pro uživatele R

Pojďme cvičit!

Python pro uživatele R

Preparing Video For Download...