Skip to content

Commit

Permalink
small improvements to plot2D (plot.networx)
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausVigo committed Jul 17, 2024
1 parent e1ed30e commit 3382471
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions R/plot_networx.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ plot.networx <- function(x, type = "equal angle", use.edge.length = TRUE,
plot2D(coord, x, show.tip.label = show.tip.label,
show.edge.label = show.edge.label, edge.label = edge.label,
show.node.label = show.node.label, node.label = node.label,
show.nodes = show.nodes, tip.color = tip.color, edge.color = edge.color,
#show.nodes = show.nodes,
tip.color = tip.color, edge.color = edge.color,
edge.width = edge.width, edge.lty = edge.lty, font = font, cex = cex,
cex.node.label = cex.node.label, cex.edge.label = cex.edge.label,
col.node.label = col.node.label, col.edge.label = col.edge.label,
Expand Down Expand Up @@ -408,24 +409,27 @@ plot2D <- function(coords, net, show.tip.label = TRUE, show.edge.label = FALSE,
xx <- coords[, 1]
yy <- coords[, 2]
nTips <- length(label)
offset <- max(nchar(label)) * 0.018 * cex * diff(range(xx))
if(is.null(xlim)){
xlim <- range(xx)
offset <- max(nchar(label)) * 0.018 * cex * diff(xlim)
# offset <- max(nchar(label)) * 0.018 * cex * diff(xlim)
if (show.tip.label) xlim <- c(xlim[1] - offset, xlim[2] + offset)
}
if(is.null(ylim)){
ylim <- range(yy)
if (show.tip.label){
if(direction=="axial"){
offset <- max(nchar(label)) * 0.018 * cex * diff(ylim)
# offset <- max(nchar(label)) * 0.018 * cex * diff(ylim)
ylim <- c(ylim[1] - offset, ylim[2] + offset)
} else ylim <- c(ylim[1] - 0.03 * cex * diff(ylim),
ylim[2] + 0.03 * cex * diff(ylim))
}
}
if (!add) {
plot.new()
plot.window(xlim, ylim, asp = 1)
# plot.new()
# plot.window(xlim, ylim, asp = 1, ...)
plot.default(0, type = "n", xlim = xlim, ylim = ylim, xlab = "",
ylab = "", axes = FALSE, asp = 1, ...)
}
cladogram.plot(edge, xx, yy, edge.color, edge.width, edge.lty)
if (show.tip.label) {
Expand Down

0 comments on commit 3382471

Please sign in to comment.