Closed nickschurch closed 1 year ago
Line widths in ggplot
are nowadays set with linewidth
, and I've now added arguments edge.linewidth
, int.linewidth
, and ext.linewidth
arguments for controlling the different types of edge widths, hopefully with more reasonable defaults than the standard defaults.
The gg.inla.mesh
interface could use some general improvements, but to allow backwards compatibility, that will likely be done as part of the coming fmesher
package instead.
Sounds reasonable. In the mean time, if others come across this and want to be able to to this, this is the custom function I'm using to plot the mesh with a variable line width:
plot.inla.mesh <- function(data, edge.color, edge.width){
# pull out the graph info into a dataframe and rename the columns
# this code is straight from inlabrus `gg.inla.mesh`
df <- rbind(
data.frame(a = data$loc[data$graph$tv[, 1], c(1, 2)],
b = data$loc[data$graph$tv[, 2], c(1, 2)]),
data.frame(a = data$loc[data$graph$tv[, 2], c(1, 2)],
b = data$loc[data$graph$tv[, 3], c(1, 2)]),
data.frame(a = data$loc[data$graph$tv[, 1], c(1, 2)],
b = data$loc[data$graph$tv[, 3], c(1, 2)])
)
colnames(df) <- c("x", "y", "xend", "yend")
# create the aes for the new ggplot geom
mp <- ggplot2::aes(x = .data$x, y = .data$y,
xend = .data$xend, yend = .data$yend)
# add the geom_segments with adjustable size parameter
msh <- ggplot2::geom_segment(data = df, mapping = mp, color = edge.color,
size = edge.width)
# return the mesh geom
return(msh)
}
The updates I made yesterday already implemented that (see https://github.com/inlabru-org/inlabru/issues/188#issuecomment-1505551321), but with separate control for regular edges and for interior/exterior constraint edges. Please check the latest development version (e.g. install from universe) and let me know if there's still something missing. (You version will also generate a warning with recent ggplot versions, since size
should be linewidth
since last year)
I have inlabru installed via conda, but I'll check it out in a different env if/when I get a mo. I'm sure it works though ;)
Reoponed, since solution not on CRAN yet.
Solved by #193
It would be nice to be able to change the line width when plotting an inla mesh with the
gg
function. I think all that's required is to change thegg.inla.mesh
function to accept a new 'size' parameter (line 732,ggplot.R
) and addingsize = size
to the geom_segment call on line 777: