learn

data science, machine learning & AI

I just started this one

###################
# Plot in Python
###################

from matplotlib import pyplot as plt

# Median Developer Salaries by Age
ages_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]

dev_y = [38496, 42000, 46752, 49320, 53200,
         56000, 62316, 64928, 67317, 68748, 73752]

# Median Python Developer Salaries by Age
py_dev_y = [45372, 48876, 53850, 57287, 63016,
            65998, 70003, 70000, 71496, 75370, 83640]

# Median Jave Develper Salaries by Age
js_dev_y = [37810, 43515, 46823, 49293, 53437,
            56373, 62375, 66674, 68745, 68746, 74583]

if __name__ == '__main__':
    # print(plt.style.available)
    plt.style.use('ggplot')

    line1, = plt.plot(ages_x, dev_y ,'y--o', label='devs')
    line2, = plt.plot(ages_x, py_dev_y, 'r-.', label='py devs')
    line3, = plt.plot(ages_x, js_dev_y, color = '#5a7d9a', linewidth =3, label='java devs')

    plt.xlabel('ages')
    plt.ylabel('salary')
    plt.title('USA salary by age')

    plt.legend(handles=[line2, line1, line3])

    plt.grid(True)
    plt.tight_layout()

    plt.savefig('plot.png')   # can add path
    plt.show()

The above code will show us how to get the plot in a nice way as the line chart. I feel it is important. This depends on the following math formula

$$ \int_{i=1}^n $$