Вопрос

Я хочу использовать grid.table () в существующий график в R. Однако я не могу найти эту таблицу на правой стороне моей графики.Так что дело:

Прежде всего, я делаю гистограмму своих данных:

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])))
.

После этого я реализовал функцию, которая запланирована в существующем графике кривой WIBULL, давая оба параметра 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)
.

Проблема в том, что эта таблица появляется в центре устройства перед гистограммой и кривой, и я хочу, чтобы он был в правой части.

Ведь я хотел бы узнать инструмент, который нажал на график, я бы получил область под моей кривой Weibull.

Это было полезно?

Решение

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