python - How to get circles into correct subplot in matplotlib? -


i trying recreate https://www.youtube.com/watch?v=lznjc4lo7le

i able plot circles want in matplotlib, want have 2 subplots next each other circles in left subplot. guess don't understand ax1,ax2 variables, because lines wind in left subplot, , circles in right subplot.

i need them both in left subplot can put sinusoids in right subplot. think mistake simple trying ax1.circle crashes because circle callable plt. ideas?

here code:

def harmonics( branches, colors, t, dotsize=2, blur=true, circles=true,save=false, newdir=false, prefix='',path='',note=''):     txt=''     ds=[]     f, (ax1, ax2) = plt.subplots(1, 2, sharey=true) #    ax1.plot(x, y) #    ax1.set_title('sharing y axis') #    ax2.scatter(x, y)      ct2, b in enumerate(branches):          d,p,l,k,n = b[0],b[1],b[2],b[3],b[4]         ds.append(sum([np.absolute(val) val in d]))         col = colors[ct2]         = ramify(b,t)         r = [0+0j]          coll=np.array([])         fig = plt.gcf()         kirkulos={}          ct,a in enumerate(a):             x in range(len(a)):                 if x == 0:                     ax1.plot([r[ct].real,float(a[x].real)+r[ct].real],[r[ct].imag,float(a[x].imag)+r[ct].imag],col,ms=dotsize+2)#color='#ff4d4d',label='python')                     rr = float(a[x].real)+r[ct].real + (float(a[x].imag)+r[ct].imag)*1j                      r.append(rr)                 else:                     pass#plt.plot([r[ct].real,float(a[x].real)+r[ct].real],[r[ct].imag,float(a[x].imag)+r[ct].imag],color='#ffffff',ms=dotsize,label='python')             if circles:                 kirkulos[ct]=plt.circle((r[ct].real,r[ct].imag),d[ct],color=col[-1],  fill=false)                     plt.gca().add_artist(kirkulos[ct])             coll = np.append(coll,a)      plt.axis("equal")     limit=max(ds)+max(ds)*.2     plt.xlim((-limit,limit))     plt.ylim((-limit,limit))     plt.ylabel('iy')     plt.xlabel('x')      ct,b in enumerate(branches):# in rami.keys():         d,p,l,k,n = b[0],b[1],b[2],b[3],b[4]         txt = txt +'\n\n'+str(d)+'\t radius'+'\n'+str(p)+'\t phase'+'\n'+str(l)+'\t order'+'\n'+str(k)+'\t frequency'+'\n'+str(n)+'\t degree'     txt=txt+'\n\n'+note     fig.set_size_inches(10,10)     if save:         if newdir:             import time             import os             = str(time.time())+'/'             os.makedirs(path+now)             path = path+now         f=open(path+prefix+'.txt','wb+')         f.write(txt)         f.close()         plt.savefig(path+prefix+'.jpg')     plt.show()  

circle generates patch, calling not add cirlce subplot (axes). done plt.gca().add_artist(kirkulos[ct]). gca stands current axes , return active subplot, replacing ax do: ax1.add_artist(kirkulos[ct])


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -