speed-tests-2.html
001| """Speed Test Chart."""
002|
003| from os import path
004| from datetime import datetime, timedelta
005| from math import sqrt
006| import matplotlib.pyplot as plt
007| from matplotlib.ticker import NullLocator, MultipleLocator, NullFormatter, FormatStrFormatter
008|
009| BasePath = r'C:\CJS\prj\Python\charts'
010| ImgsPath = path.join(BasePath,'img')
011| Filename = 'speed-tests-2.png'
012| print()
013|
014| DataSet = [
015| [22, 7, 29.5, 19.2], [22, 1, 25.6, 48.1], [23, 1, 23.6, 42.7], [22, 1, 25.6, 46.6],
016| [23, 1, 34.6, 48.2], [23, 15, 23.8, 48.2], [35, 61, 5.9, 6.2], [25, 15, 16.4, 46.0],
017| [22, 1, 27.9, 46.9], [23, 3, 28.5, 12.0], [23, 1, 14.8, 45.5], [21, 1, 21.4, 32.3],
018| [21, 1, 17.3, 3.7], [21, 2, 16.4, 3.8], [33, 16, 22.3, 35.2], [22, 1, 15.1, 15.5],
019| [22, 1, 27.4, 43.5], [23, 1, 31.4, 39.7], [21, 59, 44.8, 48.2], [23, 2, 50.4, 48.1],
020| [23, 1, 44.1, 47.9], [25, 10, 13.3, 26.5], [22, 3, 11.5, 33.4], [23, 44, 10.9, 32.9],
021| [22, 5, 12.6, 29.4], [24, 10, 11.0, 14.8], [22, 2, 24.4, 43.4], [22, 0, 31.6, 45.4],
022| [22, 1, 43.4, 47.5], [22, 1, 54.8, 48.3], [23, 1, 47.2, 47.8], [22, 1, 38.3, 48.0],
023| [22, 1, 0.0, 0.0],
024| [17, 20, 37.7, 24.5], [16, 3, 38.0, 26.2], [17, 4, 35.6, 32.2], [17, 6, 35.2, 25.1],
025| [17, 5, 41.0, 24.5], [17, 4, 36.6, 25.4], [19, 1, 37.9, 24.8], [18, 2, 37.2, 25.6],
026| [20, 1, 38.7, 21.3], [19, 2, 37.1, 21.9], [19, 3, 43.0, 24.5], [17, 7, 41.4, 5.0],
027| [18, 2, 35.7, 23.4], [15, 4, 41.9, 24.6], [17, 2, 47.7, 5.1], [18, 1, 38.4, 23.9],
028| [15, 4, 39.9, 25.1], [19, 8, 36.6, 22.8], [18, 5, 42.8, 5.3], [19, 1, 40.8, 25.3],
029|
030|
031| ]
032|
033| xs = [x+1 for x in range(len(DataSet))]
034| ys1 = [x[2] for x in DataSet]
035| ys2 = [x[3] for x in DataSet]
036|
037| fig, ax = plt.subplots()
038| fig.suptitle('WiFi Speed Tests')
039|
040| ax.set_xlabel('Test #')
041| ax.set_xlim(xs[0]-1, xs[-1]+1)
042| ax.xaxis.set_major_locator(MultipleLocator(10))
043| ax.xaxis.set_minor_locator(MultipleLocator(1))
044| ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
045|
046| for tick in ax.xaxis.get_major_ticks():
047| tick.label1.set_rotation('vertical')
048| tick.label1.set_size(9)
049|
050| ax.set_ylabel('Speed (mbs)')
051| ax.set_ylim(+0.0, +70.0)
052| ax.yaxis.set_major_locator(MultipleLocator(10.0))
053| ax.yaxis.set_minor_locator(MultipleLocator(1.0))
054| ax.yaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
055|
056| ax.grid(which='major', axis='both', color='#7f7f7f', lw=1.2,ls='-',zorder=1, alpha=1.0)
057| ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
058| ax.tick_params(which='major', axis='both', direction='out', color='#000000')
059| ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
060|
061| ax.plot(xs,ys1, color='#ff0000', label='Upload', lw=1.2, marker='o', ms=5, alpha=0.7, zorder=9)
062| ax.plot(xs,ys2, color='#0000ff', label='Dnload', lw=1.2, marker='o', ms=5, alpha=0.7, zorder=8)
063| ax.legend(loc='upper left', bbox_to_anchor=(0.0,1.0), shadow=True, fontsize=12)
064|
065| fig.set_figwidth(8.0)
066| fig.set_figheight(6.0)
067| fig.subplots_adjust(left=0.11, right=0.99, bottom=0.11, top=0.92)
068|
069| fn = path.join(ImgsPath, Filename)
070| fig.savefig(fn)
071| print('wrote: %s' % fn)
072| print()
073|
074| print()
075|
076| '''eof'''
077|