@@ -562,10 +562,10 @@ has_flipped_aes <- function(data, params = list(), main_is_orthogonal = NA,
562
562
}
563
563
564
564
# Is there a single actual discrete position
565
- y_is_int <- is.integer (y )
566
- x_is_int <- is.integer (x )
567
- if (xor(y_is_int , x_is_int )) {
568
- return (y_is_int != main_is_continuous )
565
+ y_is_discrete <- is_mapped_discrete (y )
566
+ x_is_discrete <- is_mapped_discrete (x )
567
+ if (xor(y_is_discrete , x_is_discrete )) {
568
+ return (y_is_discrete != main_is_continuous )
569
569
}
570
570
571
571
# Does each group have a single x or y value
@@ -586,51 +586,6 @@ has_flipped_aes <- function(data, params = list(), main_is_orthogonal = NA,
586
586
}
587
587
}
588
588
589
- # give up early
590
- if (! has_x && ! has_y ) {
591
- return (FALSE )
592
- }
593
-
594
- # Both true discrete. give up
595
- if (y_is_int && x_is_int ) {
596
- return (FALSE )
597
- }
598
- # Is there a single discrete-like position
599
- y_is_int <- if (has_y ) isTRUE(all.equal(y , round(y ))) else FALSE
600
- x_is_int <- if (has_x ) isTRUE(all.equal(x , round(x ))) else FALSE
601
- if (xor(y_is_int , x_is_int )) {
602
- return (y_is_int != main_is_continuous )
603
- }
604
-
605
- if (main_is_optional ) {
606
- # Is one of the axes all 0
607
- if (all(x == 0 )) {
608
- return (main_is_continuous )
609
- }
610
- if (all(y == 0 )) {
611
- return (! main_is_continuous )
612
- }
613
- }
614
-
615
- y_diff <- diff(sort(y ))
616
- x_diff <- diff(sort(x ))
617
-
618
- # FIXME: If both are discrete like, give up. Probably, we can make a better
619
- # guess, but it's not possible with the current implementation as very little
620
- # information is available in Geom$setup_params().
621
- if (y_is_int && x_is_int ) {
622
- return (FALSE )
623
- }
624
-
625
- y_diff <- y_diff [y_diff != 0 ]
626
- x_diff <- x_diff [x_diff != 0 ]
627
-
628
- # If none are discrete is either regularly spaced
629
- y_is_regular <- if (has_y && length(y_diff ) != 0 ) all((y_diff / min(y_diff )) %% 1 < .Machine $ double.eps ) else FALSE
630
- x_is_regular <- if (has_x && length(x_diff ) != 0 ) all((x_diff / min(x_diff )) %% 1 < .Machine $ double.eps ) else FALSE
631
- if (xor(y_is_regular , x_is_regular )) {
632
- return (y_is_regular != main_is_continuous )
633
- }
634
589
# default to no
635
590
FALSE
636
591
}
0 commit comments