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 0x7efe43fba490>]
../_images/342d7d2884a20f867f29a3eac69021e530fcadd3e6f48742bb45adece6e18faf.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/a95a452b0375a8690e24ef20ac2af200c69be946195a17533eea5b179f877a37.png
plt.plot(x,y,label="parabola")
plt.plot(x,z,label="kubická parabola")
plt.legend()
plt.grid()
../_images/75dcfc350492f471666b13973aefac36c39cbc2eeaecde118c11aa75a062f725.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/79d8d07cc77b67360ccd748aa1c8143cd463674673f1cf553530194c29ebc4bc.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 0x7efe3bc35bd0>
../_images/7dc30686702514b4588bb1d91498479177da7bb8f5570a5450237223b860c07c.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 0x7efe3ba19f90>]
../_images/ddfb599d6f4f6c194451ae396c517e9ebedd054ed38ac56264da1aec9d4b1e79.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 0x7efe3ba53d90>]
../_images/43237af8d5d4feecdb0372a038f39d35177b96b8ce6c1626542b4aa223465e16.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/ba8e7ceeb26b898d2ddc7f1be332fdb0b65171d44324daf6a22dc777dca34b6f.png