#!/usr/bin/env python3

# importing matplotlib module
from matplotlib import pyplot as plt
from matplotlib.ticker import AutoMinorLocator

# equivalent import
# import matplotlib.pyplot as plt
 
# x-axis values
x = [5, 2, 9, 4, 7]
 
# Y-axis values
y = [10, 5, 8, 4, 2]

xMin, xMax, yMin, yMax = 2, 9, 2, 10
xTicks = range(xMin-1, xMax+2, 1)
yTicks = range(yMin  , yMax+1, 2)
 
# create figure / axis object
# quadratic outlay with figsize()
# subplots(nrows=1, ncols=1,...)

_, myAxis = plt.subplots(figsize=(10,10))

# sline are the axis / border
myAxis.spines['right'].set_linewidth(0.0)
myAxis.spines['top'].set_linewidth(0.0)
myAxis.spines['bottom'].set_linewidth(4.0)
myAxis.spines['left'].set_linewidth(4.0)

# axis start/end/labels
myAxis.axis([xMin, xMax, yMin, yMax])
myAxis.set_title('boring diagram', fontweight="bold", size=16)
myAxis.set_xlabel('x-label', fontsize = 16)
myAxis.set_ylabel('y-label', fontsize = 16) 

# major ticks by default
# minor ticks need to be activated
myAxis.tick_params(width=2, length=8, labelsize=12)
myAxis.xaxis.set_minor_locator(AutoMinorLocator())
myAxis.tick_params(which='minor', length=8, width=2, color='r')

# location of ticks
plt.setp(myAxis, xticks=xTicks, yticks=yTicks)

# plotting 
line, points = myAxis.plot(x, y, "--g",            # line
               x, y, "ob")             # points

# activate line lebel box
line.set_label('my line')
points.set_label('my points')
myAxis.legend(loc='upper center', fontsize='larger')
 
plt.show()
