I want to visualize how many copies of each product category are sold (2nd column on table below) and add line that represents % market share (3rd column) Table I used sec_axis function to adjust second axis scale but it seems like data doesnt want to connect with it and it still operate on the first axis scale.
tabela %>% ggplot() +
geom_col(aes(x =`Przedział Cenowy`, y = `Sprzedaz przypadająca na jeden tytuł `),
fill = "blue", alpha = .4)+
geom_point(aes(x =`Przedział Cenowy`, y = `Liczba Sprzedanych Kopii / Całkowitą sprzedaż [%]`), color= "red") +
geom_line(aes(x =`Przedział Cenowy`, y = `Liczba Sprzedanych Kopii / Całkowitą sprzedaż [%]`), color= "red") +
scale_y_continuous(sec.axis = sec_axis(~./2800, name = "Procent"))
Running code adds the second axis as desired with correct units that should allow to visualize % market share but points and lines look like they still operate on the first axis.
Chart result
When I change ylim=c(0,150)
it looks like that
changed ylim
So for me it clearly looks like points and line are still operating on the first not the second axis. How could I fix it?