Aligning grid lines in R, bReeze package

余生长醉 提交于 2019-12-12 14:19:16

问题


I am trying to get grid lines work properly in the image below. Using the bReeze package to plot the power curves of the turbines with:

library(bReeze)
pc=pc("Vestas_V90_1.8MW.wtg") 
plot(pc)

The output plot is:

but assigning grid lines to the plot with the help of:

grid()

gives the image below:

Any suggestions on how to fix the distorted grid lines?


回答1:


If you don't give some arguments (e.g., mar, xlim, ylim), plot(pc) uses par(mar = c(5, 5, 1, 5) and treats data.ranges as xlim and ylim. By using these properties, you can use 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)



来源:https://stackoverflow.com/questions/37994607/aligning-grid-lines-in-r-breeze-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!