我想在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])))
.

之后,我已经在现有图表中实现了绘图的函数,威布尔曲线给出参数a和k:

plot_weibull(K_value,A_value)
.

最后我想使用grid.table()汇编,因为它以非常漂亮的形式显示单元格,并且您可以在单元格中使用斜体和粗体文本。

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top