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
매니지플리터(manageflitter)로 언팔로어 일괄 정리하기 2012-09-072023-09-03 여러가지 조건으로 대량언팔을 할 수 있는 사이트를 소개합니다. 물론 제가 만든 언팔매니저 http://uf.pubmd.net 사이트도 있지만, 아래 사이트가 훨씬 강력합니다. http://manageflitter.com 대량 팔로우를 하는 거면 몰라도 대량 언팔하는 기능이 왜 필요하냐고 물으실 수도 있는데, 트위터에서 팔로잉을 하기 위해서는 총 팔로잉의 약 90%에 해당하는 팔로어가 받쳐줘야 추가 팔로잉을 할 수 있습니다. 그러므로… Share this:FacebookX Read More
자동으로 rar로 압축해서 ftp로 백업해주는 스크립트 2009-04-212014-05-03 윈도를 사용하는 컴퓨터에서 “예약된 작업”을 이용해 하루에 한번씩 실행하도록 하고 있습니다. DOS용 RAR을 이용해 압축을 한 뒤, ftp의 put 명령을 이용해 서버의 지정된 폴더에 업로드하고, 압축 파일을 삭제해버립니다. 소스를 소개합니다. autoback.cmd REM auto backup script by mahler83 REM please give feedbacks to bomool.net @echo off rar32.exe a -o+ -ag+YYYY-MM-DD -ep1… Share this:FacebookX Read More
Lab Stuff Pubmed에서 검색 안되는 한글논문 endnote에 추가하기 2017-03-022023-07-19 펍메드에서 검색이 안 되는 한글논문을 엔드노트로 인용할 필요가 있어서 다음과 같이 진행했습니다. 1. Google Scholar에서 한국어 웹 검색 2. 검색 결과 아래에 나오는 ‘인용’ 클릭 3. 레이어팝업으로 뜨는 화면에서 ‘Endnote’클릭 → 이렇게 하면 enw 파일이 다운받아짐. 4. 다운받은 파일을 실행하면 endnote의 ‘Imported References’ 항목으로 추가가 된다. 5…. 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