I am facing a few issues regarding the sec.axis
. The following is my code. I'm trying to plot the Asking price on the left side and the Area on the right side with the x-axis showing the District. Both the values can be shown on the graph but the Area values are not distributing according to the secondary axis, it's still showing display according to the primary Y-axis.
picture:
ggplot(df2,mapping = aes(x=District.))+
geom_bar(aes(y=Asking/1000),stat="identity") +
geom_line(data=df2, aes(x=District., y=Area, group=1), inherit.aes = FALSE) +
scale_y_continuous(sec.axis = sec_axis(~ .*0.4, name = "Area")) +
theme_light() +
theme(axis.text.x = element_text(angle = 90, hjust=1),
axis.text.y = element_text(color = 'green'),
axis.title.y = element_text(color='green'),
axis.text.y.right = element_text(color = 'blue'),
axis.title.y.right = element_text(color='blue'))