import numpy as npy import matplotlib.pyplot as plt import csv names = [] values = [] with open('marketCap.txt', 'r') as infile: csv_reader = csv.reader(infile, delimiter=';') for line in csv_reader: names.append(line[0].strip()) #Calculate ratio of traded value (Lakh) and M-Cap (Crore) # x is in % as 100 Lakh = 1 Crore x = float(line[3].strip()) / float(line[2].strip()) values.append(x) infile.close() fig = plt.figure(1) #Prepare the plot ax = fig.add_subplot(111) #Define a sub-plot fig.set_size_inches(9.0,6.0) #plt.rcParams["figure.figsize"]=(W,H) # get the current axes, creating them if necessary: #axs = plt.gca() # plt.title("Free-Float M-Cap vs. Trading Volume") plt.xlabel("Scrip Name") plt.ylabel("Trade/M-Cap (%)") # # use keyword args: plt.setp(lines, color='r', linewidth=1.0) # MATLAB style: plt.setp(lines, 'color', 'r', 'linewidth', 1.0) # plt.plot(names, values, marker='s', ms=3, linewidth=1.0, linestyle='dashed') # #Borders or spines of the plot and margin/padding (% of plot width/height) #ax.spines['left'].set_position('zero') #ax.spines['bottom'].set_position(('data',0)) #ax.spines['right'].set_visible(False) ax.margins(x=0.01, y=0.01) # set the locations and labels of the xticks plt.xticks(npy.arange(len(names)), names) # plt.xticks(rotation=90) plt.tick_params(axis='both', which='major', labelsize=8) plt.tick_params(axis='both', which='minor', labelsize=7) plt.grid(alpha=0.25) #Transparency/opaqeness of grid-lines # plt.subplots_adjust(bottom=0.2) plt.grid(True) plt.savefig('Mcap_TradeValue.png', dpi=100) plt.show()