Skip to content

Commit 52552f7

Browse files
trekonomcpsievert
andauthored
Add fix to take account of linebreaks in yaxis ticklabels. (#1791)
* Add fix to take account of linebreaks in yaxis ticklabels. * Remove unnecessary sapply. * Add test linebreaks are taken into account. * Update R/ggplotly.R Co-authored-by: Carson Sievert <[email protected]> * Update R/ggplotly.R Co-authored-by: Carson Sievert <[email protected]> Co-authored-by: Carson Sievert <[email protected]>
1 parent 9a856ae commit 52552f7

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

R/ggplotly.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ gg2list <- function(p, width = NULL, height = NULL,
806806

807807
# do some stuff that should be done once for the entire plot
808808
if (i == 1) {
809-
axisTickText <- longest_element(axisObj$ticktext)
809+
# Split ticktext elements by "\n" to account for linebreaks
810+
axisTickText <- strsplit(as.character(axisObj$ticktext), split = "\n", fixed = TRUE)
811+
axisTickText <- longest_element(unlist(axisTickText))
810812
side <- if (xy == "x") "b" else "l"
811813
# account for axis ticks, ticks text, and titles in plot margins
812814
# (apparently ggplot2 doesn't support axis.title/axis.text margins)
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)