LA 1

Author

Gagana L , Anusha M.S

LA 1

Develop an interactive scatter plot to analyze relationships between two continuous variables.

Step 1: Create an Interactive Scatter Plot in R

# Load necessary libraries
library(plotly)
Loading required package: ggplot2

Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':

    last_plot
The following object is masked from 'package:stats':

    filter
The following object is masked from 'package:graphics':

    layout
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
# Create the plot
plot_ly(data = mtcars, x = ~mpg, y = ~disp, type = 'scatter', mode = 'markers', color = ~cyl) %>%
  layout(
    title = "Miles per Gallon vs Displacement",
    xaxis = list(title = "Miles per Gallon"),
    yaxis = list(title = "Displacement")
  )