Animate Stars in Different Directions

Animate Stars in Different Directions

In [1]:
import matplotlib.pyplot as plt 

Plot star

In [2]:
plt.plot(1, 2, marker = '*', markersize = '20')
plt.show()

Plot 10 stars in horizontal line

In [3]:
plt.plot(1, 2, marker = '*', markersize = '20')
plt.plot(2, 2, marker = '*', markersize = '20')
plt.plot(3, 2, marker = '*', markersize = '20')
plt.plot(4, 2, marker = '*', markersize = '20')
plt.plot(5, 2, marker = '*', markersize = '20')
plt.plot(6, 2, marker = '*', markersize = '20')
plt.plot(7, 2, marker = '*', markersize = '20')
plt.plot(8, 2, marker = '*', markersize = '20')
plt.plot(9, 2, marker = '*', markersize = '20')
plt.plot(10, 2, marker = '*', markersize = '20')

plt.show()

Plot 10 stars with range

In [4]:
for i in range(10):
    print(i)
    pass
0
1
2
3
4
5
6
7
8
9
In [ ]:
 
In [ ]:
 
In [5]:
for i in range(10):
    print(i)
    pass
0
1
2
3
4
5
6
7
8
9
In [6]:
for i in range(10):
    print(i)
0
1
2
3
4
5
6
7
8
9
In [7]:
for i in range(10):
    x = i
    y = 2
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
    pass
0 2
1 2
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
In [8]:
for i in range(10):
    x = i
    y = 2
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
0 2
1 2
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2

Plot 10 stars vertically up

In [9]:
for i in range(10):
    x = 2
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9

Plot 10 stars diagonally up right side

In [10]:
for i in range(10):
    x = i
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9

Plot 10 stars diagonally opposite side

In [11]:
for i in range(10):
    x = 10 - i
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
10 0
9 1
8 2
7 3
6 4
5 5
4 6
3 7
2 8
1 9

Move star horizontally to right side

Create figure, camera

Plot in the figure and take snapshots

Save to gif file with writer=imagemagick

In [12]:
from celluloid import Camera
In [13]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x = i
    y = 2
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
    cam.snap()
    
animation = cam.animate()
animation.save('output/stars-moving-horizontally.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
0 2
1 2
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2

Move star vertically up

In [14]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x = 2
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
    cam.snap()
    
animation = cam.animate()
animation.save('output/stars-moving-vertically.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9

Move star diagonally up

In [15]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x = i
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
    cam.snap()

    
animation = cam.animate()
animation.save('output/stars-moving-diagonally.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9

Move star diagonally opposite side

In [16]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x = 10 - i
    y = i
    print(x, y)
    plt.plot(x, y, marker = '*', markersize = '20')
    cam.snap()

    
animation = cam.animate()
animation.save('output/stars-moving-diagonally-in-opposite-direction.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
10 0
9 1
8 2
7 3
6 4
5 5
4 6
3 7
2 8
1 9

Move one star horizontally right side and one star vertically up

In [17]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x1 = i
    y1 = 2
    print(x1, y1)
    plt.plot(x1, y1, marker = '*', markersize = '20')
    
    x2 = 2
    y2 = i
    print(x2, y2)
    plt.plot(x2, y2, marker = '*', markersize = '20')
    cam.snap()

animation = cam.animate()
animation.save('output/stars-moving-right-and-up.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
0 2
2 0
1 2
2 1
2 2
2 2
3 2
2 3
4 2
2 4
5 2
2 5
6 2
2 6
7 2
2 7
8 2
2 8
9 2
2 9

Move one star horizontally right side and one star diagonally up

In [18]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x1 = i
    y1 = 2
    print(x1, y1)
    plt.plot(x1, y1, marker = '*', markersize = '20')
    
    x2 = i
    y2 = i
    print(x2, y2)
    plt.plot(x2, y2, marker = '*', markersize = '20')
    cam.snap()
    
animation = cam.animate()
animation.save('output/stars-moving-right-and-diagonally-up.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
0 2
0 0
1 2
1 1
2 2
2 2
3 2
3 3
4 2
4 4
5 2
5 5
6 2
6 6
7 2
7 7
8 2
8 8
9 2
9 9

Move three stars together

  1. One star go to the horizontally right side
  2. One star go to the vertically up
  3. One star go to diagonally up
In [19]:
fig = plt.figure()
cam = Camera(fig)

for i in range(10):
    x1 = i
    y1 = 2
    print(x1, y1)
    plt.plot(x1, y1, marker = '*', markersize = '20')
    
    x2 = i
    y2 = i
    print(x2, y2)
    plt.plot(x2, y2, marker = '*', markersize = '20')

    x3 = 2
    y3 = i
    print(x3, y3)
    plt.plot(x3, y3, marker = '*', markersize = '20')
    
    cam.snap()

    
animation = cam.animate()
animation.save('output/stars-in-different-direction.gif', writer = 'imagemagick')
MovieWriter imagemagick unavailable; using Pillow instead.
0 2
0 0
2 0
1 2
1 1
2 1
2 2
2 2
2 2
3 2
3 3
2 3
4 2
4 4
2 4
5 2
5 5
2 5
6 2
6 6
2 6
7 2
7 7
2 7
8 2
8 8
2 8
9 2
9 9
2 9

Machine Learning

  1. Deal Banking Marketing Campaign Dataset With Machine Learning

TensorFlow

  1. Difference Between Scalar, Vector, Matrix and Tensor
  2. TensorFlow Deep Learning Model With IRIS Dataset
  3. Sequence to Sequence Learning With Neural Networks To Perform Number Addition
  4. Image Classification Model MobileNet V2 from TensorFlow Hub
  5. Step by Step Intent Recognition With BERT
  6. Sentiment Analysis for Hotel Reviews With NLTK and Keras
  7. Simple Sequence Prediction With LSTM
  8. Image Classification With ResNet50 Model
  9. Predict Amazon Inc Stock Price with Machine Learning
  10. Predict Diabetes With Machine Learning Algorithms
  11. TensorFlow Build Custom Convolutional Neural Network With MNIST Dataset
  12. Deal Banking Marketing Campaign Dataset With Machine Learning

PySpark

  1. How to Parallelize and Distribute Collection in PySpark
  2. Role of StringIndexer and Pipelines in PySpark ML Feature - Part 1
  3. Role of OneHotEncoder and Pipelines in PySpark ML Feature - Part 2
  4. Feature Transformer VectorAssembler in PySpark ML Feature - Part 3
  5. Logistic Regression in PySpark (ML Feature) with Breast Cancer Data Set

PyTorch

  1. Build the Neural Network with PyTorch
  2. Image Classification with PyTorch
  3. Twitter Sentiment Classification In PyTorch
  4. Training an Image Classifier in Pytorch

Natural Language Processing

  1. Spelling Correction Of The Text Data In Natural Language Processing
  2. Handling Text For Machine Learning
  3. Extracting Text From PDF File in Python Using PyPDF2
  4. How to Collect Data Using Twitter API V2 For Natural Language Processing
  5. Converting Text to Features in Natural Language Processing
  6. Extract A Noun Phrase For A Sentence In Natural Language Processing