Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to plot the beautiful trajectory like your figure1? #8

Closed
Reeshark opened this issue Aug 27, 2018 · 2 comments
Closed

How to plot the beautiful trajectory like your figure1? #8

Reeshark opened this issue Aug 27, 2018 · 2 comments

Comments

@Reeshark
Copy link

Thanks for your amazing code. How to plot the beautiful trajectory like your figure1?

@ethanfetaya
Copy link
Owner

Thanks! The figure was done by Thomas, so I am not 100% sure, but I think he used omnigraffle.

@tkipf
Copy link
Collaborator

tkipf commented Sep 2, 2018

Thanks! It was just a very simple matplotlib script in python:

from matplotlib import cm
from numpy import linspace

start = 0.0
stop = 1.0
num_colors = 10
cm_subsection = linspace(start, stop, num_colors) 

colors = [ cm.Set1(x) for x in cm_subsection ]

for i in range(loc.shape[-1]):
    for t in range(loc.shape[0]):
        # Plot fading tail for past locations.
        plt.plot(loc[t, 0, i], loc[t, 1, i], 'o', markersize=3, 
                 color=colors[i], alpha=1-(float(t)/loc.shape[0]))
    # Plot final location.
    plt.plot(loc[0, 0, i], loc[0, 1, i], 'o', color=colors[I])

where loc is the num_timesteps x num_dims x num_objects matrix of particle trajectories. The particle trajectories are from the spring simulation.

@tkipf tkipf closed this as completed Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants