@@ -305,12 +305,28 @@ gg2list <- function(p){
305
305
ax.list $ tickangle <- - tick.text $ angle
306
306
}
307
307
ax.list $ tickfont <- theme2font(tick.text )
308
+
309
+ # # determine axis type first, since this information is used later
310
+ # # (trace.order.list is only used for type=category).
311
+ title.text <- e(s(" axis.title.%s" ))
312
+ ax.list $ titlefont <- theme2font(title.text )
313
+ ax.list $ type <- if (misc $ is.continuous [[xy ]]){
314
+ " linear"
315
+ }else if (misc $ is.discrete [[xy ]]){
316
+ " category"
317
+ }else if (misc $ is.date [[xy ]] || misc $ is.datetime [[xy ]]){
318
+ " date"
319
+ }else {
320
+ stop(" unrecognized data type for " , xy , " axis" )
321
+ }
308
322
309
323
# Translate axes labels.
310
324
scale.i <- which(p $ scales $ find(xy ))
311
325
ax.list $ title <- if (length(scale.i )){
312
326
sc <- p $ scales $ scales [[scale.i ]]
313
- trace.order.list [[xy ]] <- sc $ limits
327
+ if (ax.list $ type == " category" ){
328
+ trace.order.list [[xy ]] <- sc $ limits
329
+ }
314
330
trace.name.map [sc $ breaks ] <- sc $ labels
315
331
if (is.null(sc $ breaks )) {
316
332
ax.list $ showticklabels <- FALSE
@@ -346,18 +362,6 @@ gg2list <- function(p){
346
362
p $ labels [[xy ]]
347
363
}
348
364
349
- title.text <- e(s(" axis.title.%s" ))
350
- ax.list $ titlefont <- theme2font(title.text )
351
- ax.list $ type <- if (misc $ is.continuous [[xy ]]){
352
- " linear"
353
- }else if (misc $ is.discrete [[xy ]]){
354
- " category"
355
- }else if (misc $ is.date [[xy ]] || misc $ is.datetime [[xy ]]){
356
- " date"
357
- }else {
358
- stop(" unrecognized data type for " , xy , " axis" )
359
- }
360
-
361
365
ax.list $ zeroline <- FALSE # ggplot2 plots do not show zero lines
362
366
# Lines drawn around the plot border.
363
367
ax.list $ showline <- ! is.blank(" panel.border" , TRUE )
0 commit comments