R学习笔记 | 双坐标图
问题:什么是双坐标图?
答:
问题:为什么要画双坐标图?而不能直接将另一条曲线加进去?
答:纵坐标精度相差太大,用同一个y轴表现出来数据的变化。
一、画双坐标图的必要性
#这么画显示的不好
stock<-read_excel('stock.xlsx')
plot(stock$date,stock$SH_closing_price,type='l',ylim=c(20,5000))
lines(stock$date,stock$investor_confidence_index,lty=2)
#可以看出两个图的纵坐标精度相差很大
par(mfrow=c(1,2))
plot(stock$date,stock$investor_confidence_index,type='l',
xlab='时间',ylab='上证指数收盘价')
plot(stock$date,stock$investor_confidence_index,type='l',
xlab='时间',ylab='投资者信心指数')
下面那条线根本显示不出变化:<