2016-06-23 69 views
3

我想在下面的圖像中使網格線正常工作。使用bReeze包繪製渦輪機與功率曲線:對齊R中的網格線,bReeze包

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

輸出情節是:

Output Vestas v90 power curve

但分配網格線的幫助下劇情:

grid() 

給出下圖:

Output with grid lines

關於如何修復扭曲網格線的任何建議?

回答

1

如果你不給一些參數(例如,三月,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

+0

代碼工作,除了最後一行精,不會顯示圖形。 – SamAct

+0

@SamAct對不起,我編輯過。 – cuttlefish44