# Python 3.11 --  demo matplotlib showing tweaks on data
# Provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2024-05-01  initial release

import  os;                 os.system('clear')
import  numpy               as      np
import  matplotlib.pyplot   as      plt
from    matplotlib.ticker   import  MultipleLocator

# Line plot, show sin(x)
class Img1:

    def __init__(self):
        x = np.arange(0, 20, 0.1) 
        y = np.sin(x)

        fig, ax = plt.subplots(figsize=(8, 3), facecolor='lightskyblue', layout='constrained')
        ax.plot(x, y)
        plt.show()


# Adding labels
class Img2:

    def __init__(self):
        x = np.arange(0, 20, 0.1) 
        y = np.sin(x)

        fig, ax = plt.subplots(figsize=(8, 3), facecolor='lightskyblue', layout='constrained')
        ax.plot(x, y)

        plt.title('Matplotlib presentation of sinus')
        plt.xlabel('X-axis')
        plt.ylabel('Y-axis')
        plt.show()


# Adding grid
class Img3:

    def __init__(self):
        x = np.arange(0, 20, 0.1) 
        y = np.sin(x)

        fig, ax = plt.subplots(figsize=(8, 3), facecolor='lightskyblue', layout='constrained')
        ax.plot(x, y)

        ax.grid()
        ax.grid(color = 'green', linestyle = '--', linewidth = 0.5)

        ax.xaxis.set_major_locator(MultipleLocator(np.pi/2))
        ax.xaxis.set_major_formatter('{x:.2f}')
        ax.xaxis.set_minor_locator(MultipleLocator(np.pi/8))
        ax.yaxis.set_minor_locator(MultipleLocator(0.05))

        plt.show()


# Line attributes
class Img4:

    def __init__(self):
        x = np.arange(0, 6.3, 0.2) 
        y = np.sin(x)

        fig, ax = plt.subplots(figsize=(8, 3), facecolor='lightskyblue', layout='constrained')
        # ax.plot(x, y)
        # ax.plot(x, y, color='red')
        # ax.plot(x, y, color='red', linestyle='--')
        # ax.plot(x, y, color='red', linestyle='--', linewidth=5)
        ax.plot(x, y, color='green', marker='o')

        plt.show()


Img3()
