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
Photoshop에서 사진 여러장을 같은 각도로 회전시키기(단축키) 2013-01-042023-07-19 MRI 데이터 같은 경우 사진이 같은 각도로 돌아간 채로 여러 장 찍히게 되는데, 아래와 같은 방법으로 비교적 빠르게 같은 각도로 회전시킬 수 있었다. 같은 각도로 회전시킬 사진을 모두 드래그앤드롭으로 한꺼번에 열어두고 시작하자. ctrl+H로 그리드를 쳐놓고 회전작업을 하면 수평 맞추기가 편하다. 일단 첫 사진은 1. ctrl+A로 캔버스 전체 선택 2. 캔버스에… Share this:FacebookX Read More
Excel에서 날짜 서식 2012-02-062023-07-19 엑셀에서 날짜 서식을 지정할 때 그림처럼 요일을 함께 표시해주고 싶을 때가 있다. aaa 라고 입력하면 “월”처럼 요일을 한글자로 표시해주고, aaaa 라고 입력하면 “월요일”처럼 요일을 세글자로 표시해준다. 개인적으로 자주 쓰는 서식은 m/d(aaa) 이다. 참고로 적어놓자면, m 이라고 적으면 달을, mm 이라고 적으면 2자리수로 달을 표시해준다. d 와 dd도 마찬가지로 작동한다. Share this:FacebookX Read More
논문에서의 빈도부사 (discussion에서 percentage 표현) 2012-12-112023-08-29 논문의 discussion 부분을 쓰면서 출현 빈도를 단어로 표현할 때 참고. Always: 100%, 일주일 중 7일 Almost always: 90%, 일주일 중 6일 Usually: 70%, 일주일 중 5일 Often: 50%, 일주일 중 4일 Frequently: 30%, 일주일 중 3일 Sometimes, Occasionally: 20%, 일주일 중 2일 Seldom, Rarely: 10%, 일주일 중 1일 Never: 0%,… 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