我正在尝试让网格线在下图中正常工作。使用bReeze
包绘制涡轮机的功率曲线:
library(bReeze)
pc=pc("Vestas_V90_1.8MW.wtg")
plot(pc)
输出图是:
但在以下情况下将网格线分配给绘图:
grid()
给出下图:
有关如何修复扭曲网格线的任何建议吗?
答案 0 :(得分:1)
如果你不提出一些论点(例如,mar,xlim,ylim),
plot(pc)
使用par(mar = c(5, 5, 1, 5)
并将data.ranges视为xlim
和ylim
。通过使用这些属性,您可以使用grid()
。
pc.data = pc("Vestas_V90_1.8MW.wtg")
plot(pc.data)
par(mar = c(5, 5, 1, 5), new=T) # set par() and order to overlay
plot(pc.data[[1]], pc.data[[2]], type="n", ann=F, axes=F) # nothing but setting xy-cordinates
grid(NULL) # here, the same xy-coordinates are reproduced
# If you want to adjust grid lines to right y-axis, use berow code
:
par(mar = c(5, 5, 1, 5), new=T) # plot(pc) uses right ylim=c(0,1)
plot(pc.data[[1]], pc.data[[2]], ylim=c(0,1), type="n", ann=F, axes=F)
grid(NULL) # the xy(right)-coordinates are reproduced
# If you plot pc.object having single y-axis, use mar = c(5, 5, 1, 1)