@charts.html


001| """Blog Post Charts.
001| 
001| Commands:
001|     avb         do_a_v_b(**kwargs)
001|     lvr         do_left_v_right(**kwargs)
001|     sfvf        do_sf_v_fantasy(**kwargs)
001|     br31        do_ice_cream(**kwargs)
001| 
001|     ww          do_chart_westworld(**kwargs)
001|     pers        do_personality_space(**kwargs)
001|     beer        do_chart_beer_space(**kwargs)
001| 
001|     cplx        do_complex_number(**kwargs)
001| 
001|     test        do_test(**kwargs)
001| """

002| ####################################################################################################
003| from sys import argv, exc_info
004| from traceback import extract_tb
005| from os import path
006| from math import pi, radians, sin,cos
007| from random import random, triangular
008| import matplotlib.pyplot as plt
009| from matplotlib.ticker import NullLocator, MultipleLocator, NullFormatter, FormatStrFormatter
010| from logger import logger, info, debug, trace
011| from files import datafile, linefile
012| from goodies import KWARG
013| ####################################################################################################
014| BasePath = r'C:\CJS\prj\Python\blog\proj'
015| ImgsPath = path.join(BasePath, 'img')
016| Log = logger('Charts')
017| 
018| CMND = ''
019| ARGS = {
020|     #'real': '2.5',
021|     #'imag': '1.5',
022|     #'xmin': '-3.0', 'xmax': '+3.0',
023|     #'ymin': '-3.0', 'ymax': '+3.0',
024|     #'bot': '4.5',
025|     #'top': '9.5',
026|     #'cfg': '2',
027|     #'levels': '10.0',
028|     #'steps': '42',
029|     #'title': 'Personality Traits',
030|     #'fname': 'traits.png',
031|     'fpath': BasePath,
032| }
033| 
034| ##------------------------------------------------------------------------------------------------##
035| IceCream = [
036|     'Banana Nut Fudge',
037|     'Black Walnut',
038|     'Burgundy Cherry',
039|     'Butterscotch Ribbon',
040|     'Cherry Macaroon',
041|     'Chocolate',
042|     'Chocolate Almond',
043|     'Chocolate Chip',
044|     'Chocolate Fudge',
045|     'Chocolate Mint',
046|     'Chocolate Ribbon',
047|     'Coffee',
048|     'Coffee Candy',
049|     'Date Nut',
050|     'Egg Nog',
051|     'French Vanilla',
052|     'Green Mint Stick',
053|     'Lemon Crisp',
054|     'Lemon Custard',
055|     'Lemon Sherbet',
056|     'Maple Nut',
057|     'Orange Sherbet',
058|     'Peach',
059|     'Peppermint Fudge Ribbon',
060|     'Peppermint Stick',
061|     'Pineapple Sherbet',
062|     'Raspberry Sherbet',
063|     'Rocky Road',
064|     'Strawberry',
065|     'Vanilla',
066|     'Vanilla Burnt Almond',
067| ]
068| ##================================================================================================##
069| def do_ice_cream (**kwargs):
070|     fpath = KWARG('fpath', BasePath, str, kwargs)
071|     fname = KWARG('fname', 'BR31.out', str, kwargs)
072|     filename = path.join(fpath, fname)
073| 
074|     a = ['%s: <strong>%d</strong>' % (ic,1+int(random()*10)) for ic in IceCream]
075|     s = ', '.join(a)
076| 
077|     fout = datafile(filename)
078|     fout.data = ('[%s]' % s)
079|     fout.save()
080| 
081|     Log.info()
082|     return 'Done!'
083| 
084| 
085| ##================================================================================================##
086| def do_a_v_b (**kwargs):
087|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
088|     fname = KWARG('fname', 'a-v-b.png', str, kwargs)
089|     aname = KWARG('a', 'Dangerous', str, kwargs)
090|     bname = KWARG('b', 'Useful', str, kwargs)
091|     xvals = KWARG('x', '4.5', str, kwargs)
092|     yvals = KWARG('y', '5.5', str, kwargs)
093|     Log.info('a-v-b-chart:: %s' % str(list(kwargs.keys())))
094|     Log.info('fpath="%s"' % fpath)
095|     Log.info('fname="%s"' % fname)
096|     Log.info('a="%s"' % aname)
097|     Log.info('xvals="%s"' % xvals)
098|     Log.info('b="%s"' % bname)
099|     Log.info('yvals="%s"' % yvals)
100|     Log.info()
101|     filename = path.join(fpath, fname)
102| 
103|     xs = [float(x) for x in xvals.split(',')]
104|     ys = [float(y) for y in yvals.split(',')]
105| 
106|     fig, ax = plt.subplots()
107|     fig.suptitle('%s v. %s' % (aname,bname), fontsize=18, fontweight='bold')
108| 
109|     ax.set_xlabel(aname, fontsize=14, fontweight='bold')
110|     ax.set_xlim(0.0, +10.0)
111|     ax.xaxis.set_major_locator(MultipleLocator(1.0))
112|     ax.xaxis.set_minor_locator(MultipleLocator(0.25))
113|     ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
114| 
115|     ax.set_ylabel(bname, fontsize=14, fontweight='bold')
116|     ax.set_ylim(0.0, +10.0)
117|     ax.yaxis.set_major_locator(MultipleLocator(1.0))
118|     ax.yaxis.set_minor_locator(MultipleLocator(0.25))
119|     ax.yaxis.set_major_formatter(FormatStrFormatter('%d'))
120| 
121|     ax.grid(which='major', axis='both', color='#7f7f7f', lw=1.2,ls='-',zorder=1, alpha=1.0)
122|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
123|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
124|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
125| 
126|     ax.fill([0,0,10],[0,10,10], '#dfffdf', alpha=0.33, zorder=10)
127|     ax.fill([0,10,10],[0,10,0], '#dfdfff', alpha=0.33, zorder=10)
128|     ax.plot([0,10],[0,10], color='#005f7f', lw=2.0, ms=0, zorder=11)
129|     for x,y in zip(xs,ys):
130|         ax.axhline(y, 0, x/10.0, color='green', linewidth=1.0, zorder=13)
131|         ax.axvline(x, 0, y/10.0, color='blue', linewidth=1.0, zorder=14)
132|     ax.scatter(xs,ys, color='red', s=95, zorder=15)
133| 
134|     fig.set_figwidth(4.4)
135|     fig.set_figheight(4.4)
136|     fig.subplots_adjust(left=0.13, right=0.97, bottom=0.12, top=0.92)
137|     fig.savefig(filename)
138|     return 'Done!'
139| 
140| ##================================================================================================##
141| def do_left_v_right (**kwargs):
142|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
143|     fname = KWARG('fname', 'left-v-right.png', str, kwargs)
144|     n = KWARG('n', 50, int, kwargs)
145|     Log.info('left-v-right-chart:: %s' % str(list(kwargs.keys())))
146|     Log.info('fpath="%s"' % fpath)
147|     Log.info('fname="%s"' % fname)
148|     Log.info('n=%d' % n)
149|     Log.info()
150|     filename = path.join(fpath, fname)
151| 
152|     xs1 = [0.1 + (5.0 * triangular(mode=0.2)) for _ in range(n)]
153|     ys1 = [6.0 + (4.0 * triangular(mode=0.8)) for _ in range(n)]
154|     xs2 = [6.0 + (4.0 * triangular(mode=0.8)) for _ in range(n)]
155|     ys2 = [0.1 + (5.0 * triangular(mode=0.2)) for _ in range(n)]
156|     xs = xs1 + xs2
157|     ys = ys1 + ys2
158| 
159|     fig, ax = plt.subplots()
160|     fig.suptitle('Left v. Right', fontsize=18, fontweight='bold')
161| 
162|     ax.set_xlabel('Left', fontsize=14, fontweight='bold')
163|     ax.set_xlim(0.0, +10.0)
164|     ax.xaxis.set_major_locator(MultipleLocator(1.0))
165|     ax.xaxis.set_minor_locator(MultipleLocator(0.25))
166|     ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
167| 
168|     ax.set_ylabel('Right', fontsize=14, fontweight='bold')
169|     ax.set_ylim(0.0, +10.0)
170|     ax.yaxis.set_major_locator(MultipleLocator(1.0))
171|     ax.yaxis.set_minor_locator(MultipleLocator(0.25))
172|     ax.yaxis.set_major_formatter(FormatStrFormatter('%d'))
173| 
174|     ax.grid(which='major', axis='both', color='#7f7f7f', lw=1.2,ls='-',zorder=1, alpha=1.0)
175|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
176|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
177|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
178| 
179|     ax.fill([0,0,10],[0,10,10], '#ffdfdf', alpha=0.33, zorder=10)
180|     ax.fill([0,10,10],[0,10,0], '#dfdfff', alpha=0.33, zorder=10)
181|     ax.plot([0,10],[0,10], color='#bb00bb', lw=2.0, ms=0, zorder=11)
182|     ax.scatter(xs,ys, color='black', s=21, zorder=15)
183| 
184|     fig.set_figwidth(4.4)
185|     fig.set_figheight(4.4)
186|     fig.subplots_adjust(left=0.13, right=0.97, bottom=0.12, top=0.92)
187|     fig.savefig(filename)
188|     return 'Done!'
189| 
190| ##================================================================================================##
191| def do_sf_v_fantasy (**kwargs):
192|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
193|     fname = KWARG('fname', 'sf-v-fantasy.png', str, kwargs)
194|     n = KWARG('n', 50, int, kwargs)
195|     Log.info('sf-v-fantasy-chart:: %s' % str(list(kwargs.keys())))
196|     Log.info('fpath="%s"' % fpath)
197|     Log.info('fname="%s"' % fname)
198|     Log.info('n=%d' % n)
199|     Log.info()
200|     filename = path.join(fpath, fname)
201| 
202|     xs = [9.8] + [0.5 + (9.0 * random()) for x in range(n)]
203|     ys = [7.5] + [0.5 + (9.0 * random()) for x in range(n)]
204| 
205|     fig, ax = plt.subplots()
206|     fig.suptitle('SF v. Fantasy', fontsize=18, fontweight='bold')
207| 
208|     ax.set_xlabel('Science Fiction', fontsize=14, fontweight='bold')
209|     ax.set_xlim(0.0, +10.0)
210|     ax.xaxis.set_major_locator(MultipleLocator(1.0))
211|     ax.xaxis.set_minor_locator(MultipleLocator(0.25))
212|     ax.xaxis.set_major_formatter(FormatStrFormatter('%d'))
213| 
214|     ax.set_ylabel('Fantasy', fontsize=14, fontweight='bold')
215|     ax.set_ylim(0.0, +10.0)
216|     ax.yaxis.set_major_locator(MultipleLocator(1.0))
217|     ax.yaxis.set_minor_locator(MultipleLocator(0.25))
218|     ax.yaxis.set_major_formatter(FormatStrFormatter('%d'))
219| 
220|     ax.grid(which='major', axis='both', color='#7f7f7f', lw=1.2,ls='-',zorder=1, alpha=1.0)
221|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
222|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
223|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
224| 
225|     ax.fill([0,0,10],[0,10,10], '#ffdfdf', alpha=0.33, zorder=10)
226|     ax.fill([0,10,10],[0,10,0], '#dfdfff', alpha=0.33, zorder=10)
227|     ax.plot([0,10],[0,10], color='#bb00bb', lw=2.0, ms=0, zorder=11)
228|     #for x,y in zip(xs,ys):
229|     # ax.axhline(y, 0, x/10.0, color='red', linewidth=1.0, zorder=13)
230|     # ax.axvline(x, 0, y/10.0, color='blue', linewidth=1.0, zorder=14)
231|     ax.scatter(xs,ys, color='black', s=63, zorder=15)
232| 
233|     fig.set_figwidth(4.4)
234|     fig.set_figheight(4.4)
235|     fig.subplots_adjust(left=0.13, right=0.97, bottom=0.12, top=0.92)
236|     fig.savefig(filename)
237|     return 'Done!'
238| 
239| ##================================================================================================##
240| def do_chart_westworld (**kwargs):
241|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
242|     fname = KWARG('fname', 'westworld.png', str, kwargs)
243|     title = KWARG('title', 'Character Traits', str, kwargs)
244|     steps = KWARG('steps', 42, int, kwargs)
245|     levels = KWARG('levels', 10.0, float, kwargs)
246|     top = KWARG('top', 10.0, float, kwargs)
247|     bot = KWARG('bot',  0.0, float, kwargs)
248|     cfg = KWARG('cfg', '1,2', str, kwargs)
249|     Log.info('westworld-properties-chart:: %s' % str(list(kwargs.keys())))
250|     Log.info('fpath="%s"' % fpath)
251|     Log.info('fname="%s"' % fname)
252|     Log.info('title="%s"' % title)
253|     Log.info('levels=%f' % levels)
254|     Log.info('steps=%d' % steps)
255|     Log.info('top=%f' % top)
256|     Log.info('bot=%f' % bot)
257|     Log.info('cfg="%s"' % cfg)
258|     Log.info()
259|     filename = path.join(fpath, fname)
260| 
261|     """Random."""
262|     f1 = lambda x:(bot + (random() * (top-bot)))
263|     """Random with occasional spikes."""
264|     f2 = lambda x:(f1(x) if 0.05 < random() else (8.5+(1.5*random())))
265|     """Left/Right; extreme."""
266|     f3a = lambda x:((0.0+(3.3*random())) if x < (steps/2) else (5.0+(4.8*random())))
267|     f3b = lambda x:((0.0+(3.3*random())) if (steps/2) < x else (5.0+(4.8*random())))
268|     """Left/Right; moderate."""
269|     f4a = lambda x:((2.0+(3.5*random())) if x < (steps/2) else (5.0+(4.5*random())))
270|     f4b = lambda x:((2.0+(3.5*random())) if (steps/2) < x else (5.0+(4.5*random())))
271|     """So close."""
272|     f5xs = [f1(x) for x in range(steps)]
273|     f5 = lambda x,g:((g) if x==7 else (f5xs[x]+(-1.0+(2.0*random()))))
274|     """10 DQs."""
275|     f6 = lambda x:((0) if x<10 else f1(x))
276| 
277|     dy1 = [f1(x) for x in range(steps)]
278|     dy2 = [f1(x) for x in range(steps)]
279| 
280|     # Create a chart...
281|     ax = plt.subplot(111, polar=True, theta_offset=radians(90), theta_direction=-1)
282| 
283|     # X-axis...
284|     xs = [360.0 * (float(x)/float(steps)) for x in range(steps)]
285|     xts = [radians(x) for x in xs]
286|     xns = ['%d' % (1+x) for x in range(steps)]
287| 
288|     ax.set_xticks(xts)
289|     ax.set_xticklabels(xns)
290| 
291|     # Y-axis...
292|     yts = [n+1 for n in range(int(levels))]
293| 
294|     ax.set_ylim(0, 10)
295|     ax.set_yticks(yts)
296|     ax.set_yticklabels([])
297| 
298|     # Plot...
299|     if '1' in cfg:
300|         ax.fill(xts,dy1, color='#ffff00', alpha=0.50, zorder=10)
301|         ax.plot(xts+xts[0:1],dy1+dy1[0:1], lw=1.0, color='#7f3f1f', alpha=0.60, zorder=12)
302|         #ax.scatter(xts,dy1, c='red', marker='o',s=5, alpha=0.9, zorder=14)
303| 
304|     if '2' in cfg:
305|         ax.fill(xts,dy2, color='#00ffff', alpha=0.50, zorder=11)
306|         ax.plot(xts+xts[0:1],dy2+dy2[0:1], lw=1.0, color='#1f3f7f', alpha=0.60, zorder=13)
307|         #ax.scatter(xts,dy2, c='blue', marker='o',s=5, alpha=0.9, zorder=15)
308| 
309|     fig = plt.gcf()
310|     fig.suptitle(title, fontweight='bold')
311|     fig.set_figwidth(4.4)
312|     fig.set_figheight(4.4)
313|     fig.subplots_adjust(left=0.10, right=0.90, bottom=0.09, top=0.85)
314|     fig.savefig(filename)
315|     return 'Done!'
316| 
317| ##================================================================================================##
318| def do_personality_space (**kwargs):
319|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
320|     fname = KWARG('fname', 'personality.png', str, kwargs)
321|     title = KWARG('title', 'Personality Space', str, kwargs)
322|     levels = KWARG('levels', 10.0, float, kwargs)
323|     top = KWARG('top',10.0, float, kwargs)
324|     bot = KWARG('bot', 0.0, float, kwargs)
325|     Log.info('personality-space-chart:: %s' % str(list(kwargs.keys())))
326|     Log.info('fpath="%s"' % fpath)
327|     Log.info('fname="%s"' % fname)
328|     Log.info('title="%s"' % title)
329|     Log.info('levels=%f' % levels)
330|     Log.info('top=%f' % top)
331|     Log.info('bot=%f' % bot)
332|     Log.info()
333|     filename = path.join(fpath, fname)
334|     labels = ['open', 'conscientious', 'extroverted', 'agreeable', 'neurotic',
335|               'compliments', 'quality', 'gifts', 'service', 'touch', ]
336|     steps = len(labels)
337| 
338|     dy1 = [bot + (random() * top) for _ in range(steps)]
339|     dy2 = [bot + (random() * top) for _ in range(steps)]
340| 
341|     # Create a chart...
342|     ax = plt.subplot(111, polar=True, theta_offset=radians(90), theta_direction=-1)
343| 
344|     # X-axis...
345|     xs = [360.0 * (float(x)/float(steps)) for x in range(steps)]
346|     xts = [radians(x) for x in xs]
347| 
348|     ax.set_xticks(xts)
349|     ax.set_xticklabels(labels)
350| 
351|     # Y-axis...
352|     yts = [n+1 for n in range(int(levels))]
353| 
354|     ax.set_ylim(0, 11)
355|     ax.set_yticks(yts)
356|     ax.set_yticklabels([])
357| 
358|     # Plot...
359|     ax.fill(xts,dy1, color='#3f7fff', alpha=0.60, zorder=10)
360|     ax.plot(xts+xts[0:1],dy1+dy1[0:1], lw=1.5, color='#3f7fff', alpha=0.60, zorder=11)
361|     ax.scatter(xts,dy1, c='black', marker='o',s=15, alpha=0.9, zorder=12)
362| 
363|     fig = plt.gcf()
364|     fig.suptitle(title, fontweight='bold')
365|     fig.set_figwidth(4.4)
366|     fig.set_figheight(4.4)
367|     fig.subplots_adjust(left=0.10, right=0.90, bottom=0.09, top=0.85)
368|     fig.savefig(filename)
369|     return 'Done!'
370| 
371| ##================================================================================================##
372| def do_chart_beer_space (**kwargs):
373|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
374|     fname = KWARG('fname', 'beer-space.png', str, kwargs)
375|     levels = KWARG('levels', 10.0, float, kwargs)
376|     top = KWARG('top',10.0, float, kwargs)
377|     bot = KWARG('bot', 0.0, float, kwargs)
378|     Log.info('beer-space-chart:: %s' % str(list(kwargs.keys())))
379|     Log.info('fpath="%s"' % fpath)
380|     Log.info('fname="%s"' % fname)
381|     Log.info('levels=%f' % levels)
382|     Log.info('top=%f' % top)
383|     Log.info('bot=%f' % bot)
384|     Log.info()
385|     filename = path.join(fpath, fname)
386|     labels = ['malt1', 'malt2', 'malt3', 'malt4', 'malt5', 'malt6', 'malt7', 'malt8',
387|               'hops1', 'hops2', 'hops3', 'hops4', 'hops5', 'hops6', 'hops7', 'hops8', ]
388|     steps = len(labels)
389| 
390|     dy1 = [bot + (random() * top) for _ in range(steps)]
391|     dy2 = [bot + (random() * top) for _ in range(steps)]
392| 
393|     # Create a chart...
394|     ax = plt.subplot(111, polar=True, theta_offset=radians(90), theta_direction=-1)
395| 
396|     # X-axis...
397|     xs = [360.0 * (float(x)/float(steps)) for x in range(steps)]
398|     xts = [radians(x) for x in xs]
399| 
400|     ax.set_xticks(xts)
401|     ax.set_xticklabels(labels)
402| 
403|     # Y-axis...
404|     yts = [n+1 for n in range(int(levels))]
405| 
406|     ax.set_ylim(0, 11)
407|     ax.set_yticks(yts)
408|     ax.set_yticklabels([])
409| 
410|     # Plot...
411|     ax.fill(xts,dy1, color='#ff3311', alpha=0.50, zorder=10)
412|     ax.plot(xts+xts[0:1],dy1+dy1[0:1], lw=1.5, color='#7f3f1f', alpha=0.60, zorder=11)
413|     ax.scatter(xts,dy1, c='red', marker='o',s=5, alpha=0.9, zorder=12)
414| 
415|     ax.fill(xts,dy2, color='#1133ff', alpha=0.50, zorder=10)
416|     ax.plot(xts+xts[0:1],dy2+dy2[0:1], lw=1.5, color='#1f3f7f', alpha=0.60, zorder=11)
417|     ax.scatter(xts,dy2, c='blue', marker='o',s=5, alpha=0.9, zorder=12)
418| 
419|     fig = plt.gcf()
420|     fig.suptitle('Beer Configuration Space', fontweight='bold')
421|     fig.set_figwidth(4.4)
422|     fig.set_figheight(4.4)
423|     fig.subplots_adjust(left=0.10, right=0.90, bottom=0.09, top=0.85)
424|     fig.savefig(filename)
425|     return 'Done!'
426| 
427| ##================================================================================================##
428| def do_complex_number (**kwargs):
429|     fpath = KWARG('fpath', ImgsPath, str, kwargs)
430|     fname = KWARG('fname', 'complex.png', str, kwargs)
431|     nreal = KWARG('real',  cos(pi/4), float, kwargs)
432|     nimag = KWARG('imag',  sin(pi/4), float, kwargs)
433|     xmin  = KWARG('xmin', -1.2, float, kwargs)
434|     xmax  = KWARG('xmax', +1.2, float, kwargs)
435|     ymin  = KWARG('ymin', -1.2, float, kwargs)
436|     ymax  = KWARG('ymax', +1.2, float, kwargs)
437|     Log.info('complex-number:: %s' % str(list(kwargs.keys())))
438|     Log.info('fpath="%s"' % fpath)
439|     Log.info('fname="%s"' % fname)
440|     Log.info('nreal=%+f' % nreal)
441|     Log.info('nimag=%+f' % nimag)
442|     Log.info('xmin=%+f' % xmin)
443|     Log.info('xmax=%+f' % xmax)
444|     Log.info('ymin=%+f' % ymin)
445|     Log.info('ymax=%+f' % ymax)
446|     Log.info()
447|     filename = path.join(fpath, fname)
448|     arr_kw = dict(width=0.01, head_width=0.05, length_includes_head=True)
449|     #
450|     fig, ax = plt.subplots()
451|     fig.suptitle('Complex Number (%+.3f, %+.3fi)' % (nreal,nimag), fontsize=24, fontweight='bold')
452| 
453|     ax.set_xlabel('Real Value', fontsize=20)
454|     ax.set_xlim(xmin, xmax)
455|     ax.xaxis.set_major_locator(MultipleLocator(1.00))
456|     ax.xaxis.set_minor_locator(MultipleLocator(0.10))
457|     ax.xaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
458| 
459|     ax.set_ylabel('Imaginary Value', fontsize=20)
460|     ax.set_ylim(ymin, ymax)
461|     ax.yaxis.set_major_locator(MultipleLocator(1.00))
462|     ax.yaxis.set_minor_locator(MultipleLocator(0.10))
463|     ax.yaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
464| 
465|     ax.grid(which='major', axis='both', color='#7f7f7f', lw=1.2,ls='-',zorder=1, alpha=1.0)
466|     ax.grid(which='minor', axis='both', color='#bfbfbf', lw=0.6,ls='-',zorder=0, alpha=1.0)
467|     ax.tick_params(which='major', axis='both', direction='out', color='#000000')
468|     ax.tick_params(which='minor', axis='both', direction='out', color='#000000')
469| 
470|     ns = 45
471|     ss = [2*pi*(s/ns) for s in range(ns+1)]
472|     xs = [cos(a) for a in ss]
473|     ys = [sin(a) for a in ss]
474|     ax.plot(xs,ys, c='blue', lw=3.0, alpha=0.80, zorder=10)
475| 
476|     xs = [0.0, +1.0,  0.0, -1.0,  0.0, nreal]
477|     ys = [0.0,  0.0, +1.0,  0.0, -1.0, nimag]
478|     cs = ['black', 'black', 'black', 'black', 'black', 'red']
479|     #
480|     ax.scatter(xs,ys, color=cs, s=90, alpha=0.75, zorder=21)
481|     ax.arrow(0,0, nreal,nimag, color='black', zorder=22, **arr_kw)
482| 
483|     fig.set_figwidth(8.8)
484|     fig.set_figheight(9.2)
485|     fig.subplots_adjust(left=0.10, right=0.98, bottom=0.07, top=0.94)
486|     fig.savefig(filename)
487|     return 'Done!'
488| 
489| ##================================================================================================##
490| def do_test (**kwargs):
491|     fpath = KWARG('fpath', BasePath, str, kwargs)
492|     fname = KWARG('fname', 'test.out', str, kwargs)
493|     Log.info('test:: %s' % str(list(kwargs.keys())))
494|     Log.info('fpath="%s"' % fpath)
495|     Log.info('fname="%s"' % fname)
496|     Log.info()
497|     filename = path.join(fpath, fname)
498|     Log.info()
499|     return 'Done!'
500| ####################################################################################################
501| def dispatch (cmd, **kwargs):
502|     Log.info('command: %s' % cmd)
503|     for kw in kwargs:
504|         Log.info('argument[%s]: %s' % (kw,kwargs[kw]))
505|     Log.info()
506|     if cmd == 'avb': return do_a_v_b(**kwargs)
507|     if cmd == 'lvr': return do_left_v_right(**kwargs)
508|     if cmd == 'sfvf': return do_sf_v_fantasy(**kwargs)
509|     if cmd == 'br31': return do_ice_cream(**kwargs)
510|     if cmd == 'ww': return do_chart_westworld(**kwargs)
511|     if cmd == 'pers': return do_personality_space(**kwargs)
512|     if cmd == 'beer': return do_chart_beer_space(**kwargs)
513|     if cmd == 'cplx': return do_complex_number(**kwargs)
514|     if cmd == 'test': return do_test(**kwargs)
515|     return 'Nothing to do!'
516| ####################################################################################################
517| if __name__ == '__main__':
518|     print('autorun: %s' % argv[0])
519|     Log.start(path.join(BasePath,'charts.log'))
520|     Log.level(debug())
521|     cmd = argv[1] if 1 < len(argv) else CMND
522|     kwargs = ARGS
523|     for a in argv[2:]:
524|         nv = a.split('=', 2)
525|         kwargs[nv[0]] = (nv[1] if 1<len(nv) else '')
526|         Log.debug('%s: "%s"' % (nv[0], kwargs[nv[0]]))
527|     try:
528|         print(cmd)
529|         print()
530|         obj = dispatch(cmd, **kwargs)
531|         print()
532|         print(obj)
533|         Log.info()
534|         Log.info(obj)
535|     except:
536|         etype, evalue, tb = exc_info()
537|         ts = extract_tb(tb)
538|         Log.error()
539|         Log.error('%s: %s' % (etype.__name__,str(evalue)))
540|         for t in ts[-5:]:
541|             Log.error('[%d] %s (%s)' % (t[1], t[2], t[0]))
542|             Log.error(' %s' % t[3])
543|         raise
544|     finally:
545|         Log.end()
546| ####################################################################################################
547| '''eof'''
548|