r - 在 R 中对齐网格线,bReeze 包

标签 r plot gridlines

我正在尝试让下图中的网格线正常工作。使用 bReeze 包绘制涡轮机的功率曲线:

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

输出图是:

Output Vestas v90 power curve

但是在以下帮助下将网格线分配给绘图:

grid()

给出下图:

Output with grid lines

关于如何修复扭曲的网格线有什么建议吗?

最佳答案

如果您不提供一些参数(例如 mar、xlim、ylim), plot(pc) 使用 par(mar = c(5, 5, 1, 5) 并将 data.ranges 视为 xlimylim。通过使用这些属性,您可以使用 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)

enter image description here

关于r - 在 R 中对齐网格线,bReeze 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37994607/

相关文章:

Matlab 在一个轴上具有不同颜色的网格线

Chart.js:仅显示零索引处的水平网格线

javascript - d3.js 网格在拖动和缩放时四处移动

r - 如何用 R 中非零行最小值的 0.5 倍替换数据框中的 0 值(0.5*min)

r - 将全角字符串转换为半角字符串

r - 提取 lapply 或 mclapply 结果

r - 嵌套 for 循环到函数和 lapply

python - pandas scatter_matrix 函数中 'ax' 关键字的用途

python - 使用 matplotlib 在笛卡尔空间中绘制角度包裹的数据

r - R 中的plot.ts : Why most par()s don't work in it?