Rotating 3D t-SNE animated gif scatterplot with matplotlib mahler83, 2019-10-112023-07-19 So I’ve been through a few hours of searching + trial & error and came up with a simple solution to draw an animated GIF 3D scatterplot.(minimum library installs, exclude bash commands) X = data.iloc[:,0:-1] Y = data.iloc[:,-1].astype('int') from sklearn.manifold import TSNE tsne = TSNE(n_components=3, random_state=RS, perplexity=10) tsne_fit = tsne.fit_transform(X) n_components should be set to 3 in order to draw a 3D plot.perpliexity should be adjusted by trial and error to find the best value that represents your data. sqrt(N) is a good starting point. from mpl_toolkits.mplot3d import Axes3D from matplotlib import animation fig = plt.figure(figsize=(10,10)) ax = Axes3D(fig) colors = 'b', 'r' labels = 'Group1', 'Group2' for i, c, label in zip(range(len(labels)), colors, labels): ax.scatter(tsne_fit[data['Group']==i, 0], tsne_fit[data['Group']==i, 1], tsne_fit[data['Group']==i, 2], s=30, c=c, label=label, alpha=0.5) fig.legend() Axes3D is for 3D plotting.matplotlib.animation is for making animated GIF. Draw the scatterplot. In my case, I used scatter() twice to label the outcome feature.Added alpha=0.5 for better visualization when datapoints overlap. def rotate(angle): ax.view_init(azim=angle) angle = 3 ani = animation.FuncAnimation(fig, rotate, frames=np.arange(0, 360, angle), interval=50) ani.save('inhadr_tsne1.gif', writer=animation.PillowWriter(fps=20)) Build an arbitrary function rotate() that updates the view of the plot. This function will be called by FuncAnimation().The writer is set to PillowWriter since it’s included by default in matplotlib. But while searching, I found that in some cases there are some problems in the animation, and can be solved by using a different writer, such as FFMpegWriter.angle=3 means the plot rotates 3 degrees every frame. (120 frames in total)interval=50, fps=20 values can be tweaked to change the rotation speed of animation. bingle bangle~ Took 10 seconds to draw this.대만족! This is definitely going to be put in my next presentation! Share this:FacebookX IT Lab Stuff Tips & Techs
Academic writing RefWorks 사용하기 시작 2017-03-232023-07-19 현재 소속기관에서 Endnote 라이센스가 만료되어 신규 설치가 더이상 불가능하다고 해서 대체할만한 것을 찾다가 RefWorks라는 녀석을 발견했다. 우리 기관에서 라이센스를 구입했다고 하고, online-based로 돌아가며 협업이 가능하다고 해서 사용을 시도했다. 워드나 구글닥스에 Write-n-cite 플러그인을 설치하면 엔드노트랑 거의 비슷하게 사용할 수 있는 것 같다. 1. 일단 ac.kr 기관 이메일을 입력 2. 좋은 소식을… Share this:FacebookX Read More
Tips & Techs 사학연금 대학교 기관코드 조회 방법 2017-01-162023-07-19 사학연금 관련 서류에 “기관코드”라는 것을 기입해야 하는데, 공식적으로는 온라인 조회가 불가능하고 각 학교의 행정실을 통해 문의하도록 되어있다. 행정실에 통화를 시도했으나 “통화량이 많아 연결이 불가능합니다”라는 멘트가 뜨고, 나는 열받고… 결국 잠시 후에 전화를 걸어 코드를 확인했지만, 사학연금 홈페이지에서 비밀번호 조회를 하다가 학교별 사학연금 기관코드를 검색 가능한 페이지를 찾아냈다. http://www.tp.or.kr:8088/tp/cc/PIASItSrUF2_new.jsp?rFlag=RR&pFlag=Y&objId=cd_inst 회원가입여부… Share this:FacebookX Read More
Lab Stuff PCR Primer 디자인 방법 2013-12-112018-02-20 PCR Primer Design Guidelines. Primer 짜기 1. 길이는 18-22bp – 너무 짧으면 특이성이 떨어지고 너무 길면 tempalte에 결합하기가 힘들다 2. Tm (Melting Temperature)는 52-58도 – GC content에 의해 Tm값이 결정된다. 너무 높으면 secondary annealing이 될 수 있다. 대개 primer design할 때 값이 주어짐 3. Ta (Annealing Temperature) – Ta… Share this:FacebookX Read More
Sorry, I’ve never tried annotation. Does this help? https://stackoverflow.com/questions/56293154/axes3d-text-annotate-3d-scatter-plot