Obrázky, grafy

Obrázky, grafy#

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
x = np.linspace(-2,2,100)
y = x**2
z = x**3
plt.plot(x,y)
plt.plot(x,z)
[<matplotlib.lines.Line2D at 0x7f90d744f650>]
../_images/095f18ecb962dab2759840a13a1e4bb454c4208bef0ad9c8dd553d161adb9c14.png
fig, ax = plt.subplots(1, figsize = (10,4))
ax.plot(x,y)
ax.plot(x,z)
ax.set(
    title="Nadpis",
    xlabel="Popisek na ose x",
    ylabel="Popisek na ose y",
    xlim = (-1,None),
    ylim = (-2,4)
)
[Text(0.5, 1.0, 'Nadpis'),
 Text(0.5, 0, 'Popisek na ose x'),
 Text(0, 0.5, 'Popisek na ose y'),
 (-1.0, 2.2),
 (-2.0, 4.0)]
../_images/a6198bf15cf48059a368adc0617de580fd443493542b7abf4502d2fde75a06b0.png
plt.plot(x,y,label="parabola")
plt.plot(x,z,label="kubická parabola")
plt.legend()
plt.grid()
../_images/808527690a8288906acd160969760607a1c2ed21183af5355c5f603934f1a1d6.png
fig,ax = plt.subplots(2,1,sharex=True)
ax[0].plot(x,y,label="parabola")
ax[1].plot(x,z,label="kubická parabola")
for i,j in zip(ax,["kvadratické","kubické"]):
    i.legend()
    i.set(title="Graf "+j+" funkce")
../_images/e18c13079ead774c2eb48552bb1eac0f20d08d56fe54c94f4dd3cbf7c81d62d0.png
fig,ax = plt.subplots(3,1,sharex=True)
for i,k in enumerate([2,4,8]):
    ax[i].plot(x,np.sin(k*x),color=f"C{i}",label=rf"$\sin({k}x)$")

plt.suptitle("Grafy některých goniometrických funkcí")    
ax[2].set(xlabel="úhel (rad)")
fig.legend()
<matplotlib.legend.Legend at 0x7f90d7353ef0>
../_images/adadf9b80f1550a46590c7f24e4fc94699f464869ded153f574c35373223b2cd.png
pocet = 100
x = np.random.random(pocet)
sum = np.random.random(pocet)
y = np.exp(3*x)*(1+0.4*sum)
fig, ax = plt.subplots(1)
plt.plot(x,y,".")
#ax.set(yscale="log")
[<matplotlib.lines.Line2D at 0x7f90cf009730>]
../_images/96ce1647df98e0a188c9cdaaebbb1a890c638430cc0e57aaec7bdc194cf74555.png
x = np.linspace(0,1,100)
y = x**2
fig,ax = plt.subplots(1)
ax.plot(x,y)
# ax.set(
#     xlim=(None,None),
#     ylim=(-1,None),
#     title="Můj graf",
#     xlabel="osa x",
#     ylabel="osa y",
# )
# plt.grid()
[<matplotlib.lines.Line2D at 0x7f90cee9a8a0>]
../_images/2fa1de54645126a5e8be2867e89e742cb756035f74a84807e2a016300881c1ae.png
x = np.linspace(0,1,100)
df = pd.DataFrame(index=x)
df["y1"] = x**2
df["y2"] = x**2+.5
fig,ax = plt.subplots(1)
df.plot(ax=ax)
# ax.set(
#     xlim=(None,None),
#     ylim=(-1,None),
#     title="Můj graf",
#     xlabel="osa x",
#     ylabel="osa y",
# )
# plt.grid()
<Axes: >
../_images/f830dd3aaf344460737be33097a47d30a7b70ee918c001d59635ac0be268f218.png