-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plot rescales and normalizes graph even if it has vertex x and y attributes #1492
Comments
Thanks. I see, even without the options(conflicts.policy = list(warn = FALSE))
library(igraph)
n <- 11
a <- seq(0, 2 * pi, length.out = n + 1)[-1]
x <- 5 * cos(a)
y <- 3 * sin(a)
L <- matrix(c(x, y), ncol = 2)
G <- make_full_graph(n) |>
set_vertex_attr("x", value = x) |>
set_vertex_attr("y", value = y)
plot(G, layout = layout_nicely(G), axes = TRUE) plot(G, layout = L, rescale = FALSE, axes = TRUE) plot(G, xlim = range(V(G)$x), ylim = range(V(G)$y), rescale = FALSE, axes = TRUE) Created on 2024-09-12 with reprex v2.1.0 I'm confused why the first two plots keep the aspect ratio, but the third plot doesn't. I agree that we could do Tidyverse design guide re NULL defaults: https://design.tidyverse.org/defaults-short-and-sweet.html#null-default |
I am in the habit when plotting geographical data (which is eventually the aim here) to include
but that's way too deep in the weeds of how
which suggests that the plot function is setting But really someone who knows how these internal workings of In any case, there's a whole chunk of the code (starting at line 100) which is similar in format to above. To be clear, I am totally guessing here. I only happened on the |
What happens, and what did you expect instead?
I expect the graph drawing to be based on the
x
andy
attributes of the vertices. The documentation forlayout_nicely
saysWhen I force
xlim
andylim
to the range of those attributes, I get what I would expect by default, based on the documentation. There's a post in the forum where I asked about this, and therescale = TRUE
suggestion was made.I think the issue is with the line of code where
xlim = c(-1, 1) ylim = c(-1, 1)
is imposed.To reproduce
To be clear, the third panel is what I expect.
System information
I don't think any of this is relevant, but for completeness:
All packages updated today, and
igraph
at version 2.0.3The text was updated successfully, but these errors were encountered: