@@ -29,6 +29,50 @@ fn simple_subplot() {
29
29
plot. show ( ) ;
30
30
}
31
31
32
+ fn simple_subplot_matches_x_axis ( ) {
33
+ let trace1 = Scatter :: new ( vec ! [ 1 , 2 , 3 ] , vec ! [ 4 , 5 , 6 ] ) . name ( "trace1" ) ;
34
+ let trace2 = Scatter :: new ( vec ! [ 20 , 30 , 40 ] , vec ! [ 50 , 60 , 70 ] )
35
+ . name ( "trace2" )
36
+ . x_axis ( "x2" )
37
+ . y_axis ( "y2" ) ;
38
+
39
+ let mut plot = Plot :: new ( ) ;
40
+ plot. add_trace ( trace1) ;
41
+ plot. add_trace ( trace2) ;
42
+
43
+ let layout = Layout :: new ( ) . x_axis ( Axis :: new ( ) . matches ( "x2" ) ) . grid (
44
+ LayoutGrid :: new ( )
45
+ . rows ( 1 )
46
+ . columns ( 2 )
47
+ . pattern ( GridPattern :: Independent ) ,
48
+ ) ;
49
+ plot. set_layout ( layout) ;
50
+
51
+ plot. show ( ) ;
52
+ }
53
+
54
+ fn simple_subplot_matches_y_axis ( ) {
55
+ let trace1 = Scatter :: new ( vec ! [ 1 , 2 , 3 ] , vec ! [ 4 , 5 , 6 ] ) . name ( "trace1" ) ;
56
+ let trace2 = Scatter :: new ( vec ! [ 20 , 30 , 40 ] , vec ! [ 50 , 60 , 70 ] )
57
+ . name ( "trace2" )
58
+ . x_axis ( "x2" )
59
+ . y_axis ( "y2" ) ;
60
+
61
+ let mut plot = Plot :: new ( ) ;
62
+ plot. add_trace ( trace1) ;
63
+ plot. add_trace ( trace2) ;
64
+
65
+ let layout = Layout :: new ( ) . y_axis ( Axis :: new ( ) . matches ( "y2" ) ) . grid (
66
+ LayoutGrid :: new ( )
67
+ . rows ( 1 )
68
+ . columns ( 2 )
69
+ . pattern ( GridPattern :: Independent ) ,
70
+ ) ;
71
+ plot. set_layout ( layout) ;
72
+
73
+ plot. show ( ) ;
74
+ }
75
+
32
76
fn custom_sized_subplot ( ) {
33
77
let trace1 = Scatter :: new ( vec ! [ 1 , 2 , 3 ] , vec ! [ 4 , 5 , 6 ] ) . name ( "trace1" ) ;
34
78
let trace2 = Scatter :: new ( vec ! [ 20 , 30 , 40 ] , vec ! [ 50 , 60 , 70 ] )
@@ -289,6 +333,8 @@ fn main() {
289
333
290
334
// Subplots
291
335
// simple_subplot();
336
+ // simple_subplot_matches_x_axis();
337
+ // simple_subplot_matches_y_axis();
292
338
// custom_sized_subplot();
293
339
// multiple_subplots();
294
340
// stacked_subplots();
0 commit comments