Contents

#

#

R#

Hide code cell source
# Loading libraries
library(ggplot2)
library(gganimate)

# Defining parameters for a particle in a magnetic field
t <- seq(0, 10, by = 0.1)
x <- sin(t)
y <- cos(t)

# Creating a data frame to hold the values
particle_data <- data.frame(
  time = t,
  x = x,
  y = y
)

# Creating the plot using ggplot2 and gganimate
plot <- ggplot(particle_data, aes(x = x, y = y)) +
  geom_path(aes(group = 1), color = 'gray') + # Making sure all points are in the same group
  geom_point(size = 4) +
  labs(title = "Particle in a Magnetic Field",
       x = "X Axis",
       y = "Y Axis") +
  theme_minimal() +
  coord_fixed(ratio = 1) +
  transition_reveal(time)

# Create and save the animation
animate(plot, renderer = gifski_renderer("particle_animation.gif"))
Hide code cell output
`geom_path()`: Each group consists of only one observation.
 Do you need to adjust the group aesthetic?
`geom_path()`: Each group consists of only one observation.
 Do you need to adjust the group aesthetic?

Rendering [>--------------------------------------------] at 14 fps ~ eta:  7s

Rendering [=>-------------------------------------------] at 15 fps ~ eta:  6s

Rendering [==>------------------------------------------] at 16 fps ~ eta:  6s

Rendering [==>------------------------------------------] at 15 fps ~ eta:  6s

Rendering [===>-----------------------------------------] at 15 fps ~ eta:  6s

Rendering [===>-----------------------------------------] at 16 fps ~ eta:  6s

Rendering [====>----------------------------------------] at 16 fps ~ eta:  6s

Rendering [====>----------------------------------------] at 16 fps ~ eta:  5s

Rendering [=====>---------------------------------------] at 16 fps ~ eta:  5s

Rendering [======>--------------------------------------] at 16 fps ~ eta:  5s

Rendering [======>--------------------------------------] at 17 fps ~ eta:  5s

Rendering [=======>-------------------------------------] at 17 fps ~ eta:  5s

Rendering [========>------------------------------------] at 17 fps ~ eta:  5s

Rendering [=========>-----------------------------------] at 17 fps ~ eta:  5s

Rendering [==========>----------------------------------] at 17 fps ~ eta:  4s

Rendering [===========>---------------------------------] at 17 fps ~ eta:  4s

Rendering [============>--------------------------------] at 17 fps ~ eta:  4s

Rendering [=============>-------------------------------] at 17 fps ~ eta:  4s

Rendering [==============>------------------------------] at 17 fps ~ eta:  4s

Rendering [===============>-----------------------------] at 17 fps ~ eta:  4s

Rendering [================>----------------------------] at 17 fps ~ eta:  4s

Rendering [=================>---------------------------] at 17 fps ~ eta:  4s

Rendering [=================>---------------------------] at 17 fps ~ eta:  3s

Rendering [==================>--------------------------] at 17 fps ~ eta:  3s

Rendering [==================>--------------------------] at 16 fps ~ eta:  3s

Rendering [===================>-------------------------] at 16 fps ~ eta:  3s

Rendering [====================>------------------------] at 17 fps ~ eta:  3s

Rendering [=====================>-----------------------] at 17 fps ~ eta:  3s

Rendering [======================>----------------------] at 17 fps ~ eta:  3s

Rendering [=======================>---------------------] at 17 fps ~ eta:  3s

Rendering [========================>--------------------] at 17 fps ~ eta:  3s

Rendering [=========================>-------------------] at 17 fps ~ eta:  3s

Rendering [=========================>-------------------] at 17 fps ~ eta:  2s

Rendering [==========================>------------------] at 17 fps ~ eta:  2s

Rendering [===========================>-----------------] at 17 fps ~ eta:  2s

Rendering [============================>----------------] at 17 fps ~ eta:  2s

Rendering [=============================>---------------] at 17 fps ~ eta:  2s

Rendering [==============================>--------------] at 17 fps ~ eta:  2s

Rendering [===============================>-------------] at 17 fps ~ eta:  2s

Rendering [================================>------------] at 17 fps ~ eta:  2s

Rendering [================================>------------] at 17 fps ~ eta:  1s

Rendering [=================================>-----------] at 17 fps ~ eta:  1s

Rendering [==================================>----------] at 18 fps ~ eta:  1s

Rendering [===================================>---------] at 18 fps ~ eta:  1s

Rendering [====================================>--------] at 18 fps ~ eta:  1s

Rendering [=====================================>-------] at 18 fps ~ eta:  1s

Rendering [======================================>------] at 18 fps ~ eta:  1s

Rendering [=======================================>-----] at 18 fps ~ eta:  1s

Rendering [========================================>----] at 18 fps ~ eta:  1s

Rendering [========================================>----] at 18 fps ~ eta:  0s

Rendering [=========================================>---] at 18 fps ~ eta:  0s

Rendering [==========================================>--] at 18 fps ~ eta:  0s

Rendering [===========================================>-] at 18 fps ~ eta:  0s

Rendering [============================================>] at 18 fps ~ eta:  0s

Rendering [=============================================] at 18 fps ~ eta:  0s
                                                                              

Hide code cell source
static_plot <- ggplot(particle_data, aes(x = x, y = y)) +
  geom_path(aes(group = 1), color = 'gray') +
  geom_point(size = 4) +
  labs(title = "Particle in a Magnetic Field", x = "X Axis", y = "Y Axis") +
  theme_minimal() +
  coord_fixed(ratio = 1)
# print(static_plot)
1+5
6
"hey"
'hey'
x = 5
x
5
x = 1:100
y = 100*log(x + 1)
plot(y ~ x, type = "l")
_images/de13a146815389b73415842f2f1524e8cbfd86cc85bee98dc70601f008b9e0fd.png