@@ -353,7 +353,7 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
353
353
ticklen = unitConvert(theme $ axis.ticks.length , " pixels" , type ),
354
354
tickwidth = unitConvert(axisTicks , " pixels" , type ),
355
355
showticklabels = ! is_blank(axisText ),
356
- tickfont = text2font(axisText , " height " ),
356
+ tickfont = text2font(axisText , type ),
357
357
tickangle = - (axisText $ angle %|| % 0 ),
358
358
showline = ! is_blank(axisLine ),
359
359
linecolor = toRGB(axisLine $ colour ),
@@ -364,9 +364,8 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
364
364
gridwidth = unitConvert(panelGrid , " pixels" , type ),
365
365
zeroline = FALSE ,
366
366
anchor = anchor ,
367
- # if not facets then use Plotly axis titling mechanism
368
- # see https://github.com/ropensci/plotly/issues/510
369
- title = axisTitleText
367
+ title = axisTitleText ,
368
+ titlefont = text2font(axisTitle )
370
369
)
371
370
# convert dates to milliseconds (86400000 = 24 * 60 * 60 * 1000)
372
371
# this way both dates/datetimes are on same scale
@@ -413,8 +412,9 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
413
412
if (xy == " y" && inherits(p $ facet , " grid" )) {
414
413
gglayout $ margin $ r <- gglayout $ margin $ r + stripSize
415
414
}
416
- # draw axis titles as annotations
417
- # (plotly.js axis titles aren't smart enough to dodge ticks & text)
415
+ # facets have multiple axis objects, but only one title for the plot,
416
+ # so we empty the titles and try to draw the title as an annotation
417
+ gglayout [[axisName ]]$ title <- " "
418
418
if (nchar(axisTitleText ) > 0 ) {
419
419
# npc is on a 0-1 scale of the _entire_ device,
420
420
# but these units _should_ be wrt to the plotting region
@@ -432,13 +432,6 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
432
432
}
433
433
}
434
434
}
435
-
436
- if (has_facet(p )) {
437
- # turn off plotly axis titles
438
- # since we need special treatment for facets
439
- gglayout [[axisName ]]$ title <- " "
440
- }
441
-
442
435
} # end of axis loop
443
436
444
437
xdom <- gglayout [[lay [, " xaxis" ]]]$ domain
0 commit comments