0

i have 3 planets, the first one with eccentricity = 0,70 and semi major axis = 900, the second one with eccentricity 0,80 and semi major axis = 1200 and the third one with eccentricity = 0,90 and semi major axis = 1500. is there a way to plot this?

camille
  • 16,432
  • 18
  • 38
  • 60
  • [This](https://stackoverflow.com/questions/41820683/how-to-plot-ellipse-given-a-general-equation-in-r) might be helpful. – eipi10 Aug 27 '21 at 18:15
  • Does this answer your question? [drawing ellipses/hyperbolas in R](https://stackoverflow.com/questions/12922740/drawing-ellipses-hyperbolas-in-r) – Samet Sökel Aug 27 '21 at 19:50

1 Answers1

1

ggforce package has geom_ellipse. Just one thing, you need to provide both minor and major axis, but it's easy to calculate minor axis from major and eccentricity.

library(dplyr)
library(ggplot2)
library(ggforce)

planets <- 
  tribble(
    ~e, ~a,
    0.7, 900,
    0.8, 1200,
    0.9, 1500
  ) %>% 
  mutate(name = letters[1:n()]) %>% 
  # calculate minor axis
  mutate(b = a*sqrt(1-e^2)) %>% 
  # centers
  mutate(x0 = 0, y0 = 0)

planets %>% 
  ggplot(aes(color = name)) +
  geom_ellipse(aes(x0 = x0, y0 = y0, a = a, b = b, angle = 0)) +
  coord_fixed()

Created on 2021-08-27 by the reprex package (v2.0.1)

Iaroslav Domin
  • 2,698
  • 10
  • 19