def mplot(sage_plot, equal_scale=False, edit_res=False): """ This function convert sage_plot, created at sage, in matplotlib graph. """ plt.clf() fig = plt.figure() ax = SubplotZero(fig, 111) fig.add_subplot(ax) L = sage_plot.matplotlib().gca().lines for t in L: data = t.get_data() ax.add_line(mpl.lines.Line2D(data[0], data[1])) ax.autoscale_view() if equal_scale: ax.axis('equal') for direction in ["xzero", "yzero"]: ax.axis[direction].set_axisline_style("-|>", size=2) ax.axis[direction].set_visible(True) for direction in ["left", "right", "bottom", "top"]: ax.axis[direction].set_visible(False) ax.axis["yzero"].set_axis_direction("left") ax.minorticks_on() ax.grid() if edit_res: return (fig) else: plt.savefig('') plt.show() plt.close()
def plot_L(self): fig = plt.figure(1) ax = SubplotZero(fig, 111) fig.add_subplot(ax) for el in self.L: self.plot_box(X=el, index=0, this_color='blue', canvas=ax) ax.set_xlim(-15., 15.) ax.set_ylim(-15., 15.) ax.axis('equal') plt.show()
def plot_subpaving(self): fig = plt.figure(1) ax = SubplotZero(fig, 111) fig.add_subplot(ax) for el in self.outside: self.plot_box(X=el, index=0, this_color='red', canvas=ax) for el in self.boundary: self.plot_box(X=el, index=0, this_color='yellow', canvas=ax) for el in self.inside: self.plot_box(X=el, index=0, this_color='green', canvas=ax) ax.set_xlim(-12., 12.) ax.set_ylim(-12., 12.) ax.axis('equal') plt.show() return
def run(self, results): par1 = self.getValueOfParameter("parameter 1") par2 = self.getValueOfParameter("parameter 2") i = int(self.getValueOfParameter("iteration number")) title = self.getValueOfParameter("title") if(par1==""): return False if(par2==""): return False if(i >= results.__len__()): return False dialogform = Dialog(QApplication.activeWindow()) fig = Figure((5.0, 4.0), dpi=100) ax = SubplotZero(fig, 1, 1, 1) fig.add_subplot(ax) for n in ["top", "right"]: ax.axis[n].set_visible(False) for n in ["bottom", "left"]: ax.axis[n].set_visible(True) x = results[i].getResults(par1) y = results[i].getResults(par2) if(not(x.__len__())): return False if(not(y.__len__())): return False ax.plot(x,y,'.') #plot middle xm = range(math.floor(min(ax.axis())),math.floor(max(ax.axis())+1),1) ax.plot(xm,xm) ax.set_xlabel(par1) ax.set_ylabel(par2) ax.set_title(title) dialogform.showFigure(fig) return True
# draw measurement points ax3.plot(foursphereParams['r'][:, 0], foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites') for i, (x, y, z) in enumerate(foursphereParams['r']): # theta = np.arcsin(x / foursphereParams['radii'][-1]) # if x >= 0: # ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi)) # else: # ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right') ax3.text(x, z + 2500, r'{}'.format(i + 1), ha='center') # dipole location ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site') ax3.axis('equal') ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0, foursphereParams['radii']]) ax3.set_xticklabels([]) ax3.legend(loc=(0.25, 0.15), frameon=False) # four-sphere volume conductor sphere = LFPy.FourSphereVolumeConductor(**foursphereParams) phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position) # import example_parallel_network_plotting as plotting vlimround = draw_lineplot( ax=ax4, data=phi_p * 1E9, unit=r'pV', #mV -> pV unit conversion dt=cell.dt,
theta = np.linspace(0, np.pi, 31) # draw some circles: for i, r, label in zip(range(4), PSET.foursphereParams['radii'], ['brain', 'CSF', 'skull', 'scalp']): ax.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False) # draw measurement points ax.plot(PSET.foursphereParams['r'][:, 0], PSET.foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites') for i, (x, y, z) in enumerate(PSET.foursphereParams['r']): ax.text(x, z+2500, r'{}'.format(i+1), ha='center') # dipole location ax.plot([0], [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]], 'k.', label='dipole site') ax.axis('equal') ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000) ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0, PSET.foursphereParams['radii']]) ax.set_xticklabels([]) ax.legend(loc=(0.25, 0.05), frameon=False) ax.text(-0.1, 1.05, alphabet[5], horizontalalignment='center', verticalalignment='center', fontsize=16, fontweight='demibold', transform=ax.transAxes)
for i, r, label in zip(range(4), foursphereParams['radii'], ['brain', 'CSF', 'skull', 'scalp']): ax3.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False) # draw measurement points ax3.plot(foursphereParams['r'][:, 0], foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites') for i, (x, y, z) in enumerate(foursphereParams['r']): # theta = np.arcsin(x / foursphereParams['radii'][-1]) # if x >= 0: # ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi)) # else: # ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right') ax3.text(x, z+2500, r'{}'.format(i + 1), ha='center') # dipole location ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site') ax3.axis('equal') ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0, foursphereParams['radii']]) ax3.set_xticklabels([]) ax3.legend(loc=(0.25, 0.15), frameon=False) # four-sphere volume conductor sphere = LFPy.FourSphereVolumeConductor( **foursphereParams ) phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position) # import example_parallel_network_plotting as plotting vlimround = draw_lineplot(ax=ax4, data=phi_p*1E9, unit=r'pV', #mV -> pV unit conversion dt=cell.dt, ztransform=False,
# draw measurement points ax.plot(PSET.foursphereParams['r'][:, 0], PSET.foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites') for i, (x, y, z) in enumerate(PSET.foursphereParams['r']): ax.text(x, z + 2500, r'{}'.format(i + 1), ha='center') # dipole location ax.plot([0], [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]], 'k.', label='dipole site') ax.axis('equal') ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000) ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0, PSET.foursphereParams['radii']]) ax.set_xticklabels([]) ax.legend(loc=(0.25, 0.05), frameon=False) ax.text(-0.1, 1.05, alphabet[5], horizontalalignment='center', verticalalignment='center', fontsize=16, fontweight='demibold',
def main(): opts, args = getopt.getopt(sys.argv[1:], 'u:', ['URL=']) print("Number of arguments: " + str(len(sys.argv))) if len(sys.argv) > 1: threadID = str(sys.argv[1]) else: threadID = '3jms68' print("Using thread: " + threadID) r = praw.Reddit(user_agent='test script /u/Speff') #r.set_oauth_app_info(client_id='aDjUAlJ0Cb17pA', # client_secret='AeJjd7CLEUt7wyMmTVhP6kidhLc', # redirect_uri='http://127.0.0.1:65010/' # 'authorize_callback') #url = r.get_authorize_url('uniqueKey', 'identity', True) #print(url) #access_information = r.get_access_information('lfJfhgKEDDUzgwY9a2tcVtVYMnc') #r.set_access_credentials(**access_information) #authenticated_user = r.get_me() #print(authenticated_user.name, authenticated_user.link_karma) start = float(time.time()) submission = r.get_submission(submission_id=threadID, comment_sort="confidence") submission.replace_more_comments(limit=None, threshold=1) print("Seconds to process thread: " + str(time.time()-start)) flat_comments = praw.helpers.flatten_tree(submission.comments) submission_score = submission.score submission_time = submission.created_utc comment_score = [] comment_time = [] commentInfo = [] #comment_body = [] print("Number of comments: " + str(len(flat_comments))) for x in flat_comments: # print(x.body + "\n") comment_score.append(abs(x.score-1)+1) comment_time.append((x.created_utc - submission_time)/(60)) # comment_body.append(x.body) data = np.column_stack((comment_time, comment_score)) uniques, count = np.unique(data[:,1], return_counts=True) unvoted = 0.0 for x in range(0, len(uniques)): if(uniques[x]) == 1: unvoted = count[x] unvoted = unvoted / len(comment_time) if 1: fig = plt.figure(1) ax = SubplotZero(fig, 111) fig.add_subplot(ax) ax.axis["left"].set_label('Points') ax.axis["bottom"].set_label('Time (minutes)') xRange = np.amax(data[:,0]) - np.amin(data[:,0]) yRange = np.amax(data[:,1]) - np.amin(data[:,1]) plt.axhline(1, color='gray', linestyle='--') plt.axhline(0, color='black') plt.axvline(0, color='black') xFit = np.linspace(np.amin(data[:,0]) - xRange*0.1, np.amax(data[:,0]) + xRange*0.1, 1000) A, K, C = fit_exp_nonlinear(data[:,0], data[:,1]) fit_y = 2*model_func(xFit, A, K, C) print("Best-fit polynomial coefficient(s): " + str((A, K, C))) ax.axis([np.amin(data[:,0]) - xRange*0.1, np.amax(data[:,0]) + xRange*0.1, np.amin(data[:,1]) - yRange*0.1, np.amax(data[:,1]) + yRange*0.1]) ax.plot(data[:,0], data[:,1], '.') ax.plot(xFit, fit_y, '-', color='darkred') ax.text(0.75*xRange + np.amin(data[:,0]), 0.9*yRange + np.amin(data[:,1]), str(round(unvoted,3)*100) + '% unvoted \n', fontsize=15) plt.show()