z_polar.html


001| ####################################################################################################
002| from os import path
003| from random import random
004| import matplotlib.pyplot as plt
005| ####################################################################################################
006| BasePath = r'C:\CJS\prj\Python\charts'
007| ImgsPath = path.join(BasePath,'img')
008| 
009| 
010| ##================================================================================================##
011| def do_chart_polar ():
012|     filename = path.join(ImgsPath,'z_polar.png')
013| 
014|     # Make some data...
015|     xn   = 100
016|     xmax = 360
017|     xmin =   0
018|     ymax =  64
019|     ymin =  32
020| 
021|     xr = list(range(xn))
022|     xi = list(range(0, 360, 30))
023| 
024|     xt = [Radians(x) for x in xi]
025|     xs = [str(x) for x in xi]
026|     yt = list(range(ymin, ymax, 8))+[ymax]
027|     ys = [str(y) for y in yt]
028| 
029|     cs = [(random(),random(),random()) for x in xr]
030|     dx = [xmin + (random() * (xmax-xmin)) for x in xr]
031|     dy = [ymin + (random() * (ymax-ymin)) for x in xr]
032|     theta = [Radians(x) for x in dx]
033| 
034|     # Create a chart...
035|     ax = plt.subplot(111, polar=True)
036|     ax.set_title('Polar Chart')
037| 
038|     #ax.set_xlim(xmin, xmax)
039|     ax.set_xticks(xt)
040|     ax.set_xticklabels(xs)
041| 
042|     ax.set_ylim(ymin, ymax)
043|     ax.set_yticks(yt)
044|     ax.set_yticklabels(ys)
045| 
046|     ax.scatter(theta,dy, c=cs, marker='o',s=15, alpha=0.5)
047| 
048|     fig = plt.gcf()
049|     fig.set_figwidth(6.4)
050|     fig.set_figheight(4.8)
051|     fig.subplots_adjust(left=0.10, bottom=0.10, right=0.90, top=0.90)
052|     fig.savefig(filename)
053| 
054| 
055| ####################################################################################################
056| if __name__ == '__main__':
057|     do_chart_polar()
058| ####################################################################################################
059| '''eof'''
060|