z_test.html


001| ####################################################################################################
002| from os import path
003| from datetime import date
004| from random import random, uniform, randint, choice
005| import numpy as np
006| import matplotlib.pyplot as plt
007| from matplotlib.ticker import NullLocator, MultipleLocator, NullFormatter, FormatStrFormatter
008| from matplotlib.dates import DayLocator, DateFormatter
009| ####################################################################################################
010| BasePath = r'C:\CJS\prj\Python\charts'
011| ImgsPath = path.join(BasePath,'img')
012| 
013| 
014| ##================================================================================================##
015| def do_chart_test ():
016|     filename = path.join(ImgsPath,'z_test.png')
017| 
018|     # Make some data...
019|     sz = 10
020|     gs = [[randint(0,100) for n in range(100)] for m in range(sz)]
021|     bs = [chr(ord('a')+m) for m in range(sz)]
022|     ymin, ymax = -5.0, 105.0
023|     xt = list(range(1,6))
024| 
025|     # Create a chart...
026|     fig, ax = plt.subplots()
027|     fig.suptitle('Chart', horizontalalignment='left')
028|     ax.set_title('Test Data', loc='left', fontsize=13)
029|     ax.set_xlabel('X Axis', ha='left', fontsize=11)
030|     ax.set_ylabel('Y Axis', fontsize=11)
031|     ax.set_ylim(ymin, ymax)
032| 
033|     ax.minorticks_on()
034|     ax.set_xticks(xt)
035|     ax.yaxis.set_major_locator(MultipleLocator(25.0))
036|     ax.yaxis.set_minor_locator(MultipleLocator( 5.0))
037| 
038|     ax.grid(which='major', axis='both', color='#bfbfff', lw=1.0,ls='-', alpha=1.0, zorder=1)
039|     ax.grid(which='minor', axis='y'   , color='#dfdfff', lw=0.5,ls='-', alpha=1.0, zorder=0)
040|     ax.tick_params(which='major', axis='both', direction='out')
041|     ax.tick_params(which='minor', axis='y'   , direction='out')
042| 
043|     ax.boxplot(gs, labels=bs, widths=0.50)
044| 
045|     fig.set_figwidth(6.4)
046|     fig.set_figheight(4.8)
047|     fig.subplots_adjust(left=0.12, bottom=0.15, right=0.97, top=0.90)
048|     fig.savefig(filename)
049| 
050| 
051| ####################################################################################################
052| if __name__ == '__main__':
053|     do_chart_test()
054| ####################################################################################################
055| '''eof'''
056|