I am new to ggplotly and R and I am struggling on the simplest issue. I want to zoom in on my secondary axis so the data stand out. However simple math does not seem to be working.
Squaring and square rooting the data. Adjusting ylim
library(tidyr)
library(readxl)
library(ggplot2)
library(tidyverse)
library(plotly)
data = read_excel("./Input/VC_AV.xlsx")
data[,2:4] <- data[,2:4]/1000000
data[,5:7] <- data[,5:7]/100000
head(data)
data_clean = gather(data, "Scenario", "Value", -Time)
head(data_clean)
p <- data_clean %>%
ggplot(aes(Time, y=Value, col=Scenario)) +
geom_line(aes(linetype=Scenario)) +
scale_y_continuous(sec.axis = sec_axis(~./scale, name = "Coastal Proximity Amenity Value (NZ$M)")) +
labs(x="Time", y= ("Vulnerable Residential Capital(NZ$M)")) +
theme_minimal() +
theme(legend.position="bottom") +
p
ggplotly(p)
I wish to zoom in on the secondary y-axis to show the differences in the dataset while maintaining the original left-hand y-axis.