Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ggplotly(): fix Xaxis anchor if the last row incomplete #1501

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

Merged
merged 7 commits into from
Jul 15, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stylistic changes
  • Loading branch information
cpsievert committed Apr 3, 2019
commit 414fbe1582e8b6e6bd2f602aeb2383001d754b16
26 changes: 17 additions & 9 deletions 26 R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -459,29 +459,37 @@ gg2list <- function(p, width = NULL, height = NULL,

# panel -> plotly.js axis/anchor info
# (assume a grid layout by default)
layout$layout <- dplyr::mutate(layout$layout,
layout$layout <- dplyr::mutate(
layout$layout,
xaxis = COL,
yaxis = ROW,
xanchor = nRows,
yanchor = 1L)
yanchor = 1L
)
if (inherits(plot$facet, "FacetWrap")) {
if (plot$facet$params$free$x && plot$facet$params$free$y) {
layout$layout <- dplyr::mutate(layout$layout,
layout$layout <- dplyr::mutate(
layout$layout,
xaxis = PANEL,
yaxis = PANEL,
xanchor = PANEL,
yanchor = PANEL)
yanchor = PANEL
)
} else if (plot$facet$params$free$x) {
layout$layout <- dplyr::mutate(layout$layout,
layout$layout <- dplyr::mutate(
layout$layout,
xaxis = PANEL,
xanchor = ROW)
xanchor = ROW
)
} else if (plot$facet$params$free$y) {
layout$layout <- dplyr::mutate(layout$layout,
layout$layout <- dplyr::mutate(
layout$layout,
yaxis = PANEL,
yanchor = COL)
yanchor = COL
)
}
# anchor X axis to the lowest plot in its column
layout$layout <- dplyr::group_by(layout$layout, xaxis) %>%
layout$layout <- dplyr::group_by_(layout$layout, "xaxis") %>%
dplyr::mutate(xanchor = max(as.integer(yaxis))) %>%
dplyr::ungroup() %>%
dplyr::mutate(xanchor = if (is.factor(yaxis)) levels(yaxis)[xanchor] else xanchor)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.