質問
Rで既存のプロットでgrid.table()を使用したいのです。ただし、このテーブルはマイチャートの右側に見つかりません。だからこは:です
まず、データのヒストグラムを作成します。
hist(as.numeric(unlist((vels[counts]))),freq=F,
col="gray",border="black",ylim=c(0,0.15),
xlab=paste(names(vels)[counts]),
main=paste("Weibull fitting",names(vels[counts])))
.
その後、既存のチャートにプロットする関数を実装しました。の両方を与えるワイブルカーブ
plot_weibull(K_value,A_value)
.
と最後に私はgrid.table()を使ってdata.frameを置きたいと思います。
grid.table(round(values,3),cex=0.75,show.rownames=T,
show.colnames=T,show.hlines=T)
.
問題は、ヒストグラムと曲線の前の装置の中央にこのテーブルが表示され、右側にあることが望ましくありません。
結局のところ、グラフをクリックするツールを知りたいのですが、私は私のワイブルカーブの下の領域を受け取るでしょう。
解決
The hist
function is base graphics and the grid.table
function is grid graphics. The 2 graphics systems do not play nicely together without extra effort (as you have noticed).
The easiest fix is to use the addtable2plot
function from the plotrix
package rather than grid.table
. It may not look the same but it would be simple.
Another option is to use a grid graphics function to create the histogram, such as something from the lattice
or ggplot2
packages (both can do histograms), then create a specific viewport using grid graphics functions and use grid.table
to put the table into that viewport.
Last, if you really want to mix them then see the gridBase
package for ways to mix grid and base graphics.