Tuesday, September 14, 2021

Solving one problem from YandexQ as 14/09/2021

 















[boris@fedora34server ~]$ cat  yandexPlot.py

import matplotlib.pyplot as plt

from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,

                               AutoMinorLocator)

import numpy as np

x = np.linspace(0, 30, 30)

y1 = np.cos(np.cos(np.cos(np.cos(x))))

y2 = np.sin(np.sin(np.sin(np.sin(x))))

fig, ax = plt.subplots(figsize=(8, 6))

ax.set_title("Графики зависимостей: y1, y2", fontsize=16)

ax.set_xlabel("x", fontsize=14)        

ax.set_ylabel("y1, y2", fontsize=14)

ax.grid(which="major", linewidth=1.2)

ax.grid(which="minor", linestyle="--", color="gray", linewidth=0.5)

ax.scatter(x, y1, c="red", label="y1")

ax.plot(x, y2, label="y2")

ax.legend()

ax.xaxis.set_minor_locator(AutoMinorLocator())

ax.yaxis.set_minor_locator(AutoMinorLocator())

ax.tick_params(which='major', length=10, width=2)

ax.tick_params(which='minor', length=5, width=1)


plt.show()

[boris@fedora34server ~]$ python  yandexPlot.py


















Next iteration

[boris@fedora34server ~]$ cat  yandexPlot5.py

import numpy as np # import numpy package

import matplotlib.pyplot as plt # import matplotlib.pyplot package

x = np.arange(0,9 * np.pi, 0.1) # create x array of angels from range 0 to 9*3.14

y = np.cos(np.cos(np.cos(np.cos(x)))) -   np.sin(np.sin(np.sin(np.sin(x)))) 

plt.plot(x, y) # plot grah 

plt.title(" Graphical Representation of sine function")

plt.xlabel("x axis ")

plt.ylabel("y axis ")

plt.show() # show plotted graph






























No comments:

Post a Comment