@@ -10,6 +10,104 @@ building a complex figure step by step. This is the final result we will create:
1010
1111![ layout_tutorial_final] ( layout_tutorial_final.svg )
1212
13+ ``` @raw html
14+ <details><summary>You can click here to see the full code</summary>
15+ ```
16+
17+ ``` julia
18+ using CairoMakie
19+
20+ noto_sans = " ../assets/NotoSans-Regular.ttf"
21+ noto_sans_bold = " ../assets/NotoSans-Bold.ttf"
22+
23+ fig = Figure (backgroundcolor = RGBf0 (0.98 , 0.98 , 0.98 ),
24+ resolution = (1000 , 700 ), font = noto_sans)
25+
26+ ax1 = fig[1 , 1 ] = Axis (fig, title = " Pre Treatment" )
27+
28+ data1 = randn (50 , 2 ) * [1 2.5 ; 2.5 1 ] .+ [10 10 ]
29+
30+ line1 = lines! (ax1, 5 .. 15 , x -> x, color = :red , linewidth = 2 )
31+ scat1 = scatter! (ax1, data1,
32+ color = (:red , 0.3 ), markersize = 15 px, marker = ' ■' )
33+
34+ ax2, line2 = lines (fig[1 , 2 ], 7 .. 17 , x -> - x + 26 ,
35+ color = :blue , linewidth = 2 ,
36+ axis = (title = " Post Treatment" ,))
37+
38+ data2 = randn (50 , 2 ) * [1 - 2.5 ; - 2.5 1 ] .+ [13 13 ]
39+
40+ scat2 = scatter! (data2,
41+ color = (:blue , 0.3 ), markersize = 15 px, marker = ' ▲' )
42+
43+ linkaxes! (ax1, ax2)
44+
45+ hideydecorations! (ax2, grid = false )
46+
47+ ax1. xlabel = " Weight [kg]"
48+ ax2. xlabel = " Weight [kg]"
49+ ax1. ylabel = " Maximum Velocity [m/sec]"
50+
51+ leg = fig[1 , end + 1 ] = Legend (fig,
52+ [line1, scat1, line2, scat2],
53+ [" f(x) = x" , " Data" , " f(x) = -x + 26" , " Data" ])
54+
55+ fig[2 , 1 : 2 ] = leg
56+
57+ trim! (fig. layout)
58+
59+ leg. tellheight = true
60+
61+ leg. orientation = :horizontal
62+
63+ hm_axes = fig[1 : 2 , 3 ] = [Axis (fig, title = t) for t in [" Cell Assembly Pre" , " Cell Assembly Post" ]]
64+
65+ heatmaps = [heatmap! (ax, i .+ rand (20 , 20 )) for (i, ax) in enumerate (hm_axes)]
66+
67+ hm_sublayout = GridLayout ()
68+ fig[1 : 2 , 3 ] = hm_sublayout
69+
70+ # there is another shortcut for filling a GridLayout vertically with
71+ # a vector of content
72+ hm_sublayout[:v ] = hm_axes
73+
74+ hidedecorations! .(hm_axes)
75+
76+ for hm in heatmaps
77+ hm. colorrange = (1 , 3 )
78+ end
79+
80+ cbar = hm_sublayout[:, 2 ] = Colorbar (fig, heatmaps[1 ], label = " Activity [spikes/sec]" )
81+
82+ cbar. height = Relative (2 / 3 )
83+
84+ cbar. ticks = 1 : 0.5 : 3
85+
86+ supertitle = fig[0 , :] = Label (fig, " Complex Figures with Makie" ,
87+ textsize = 24 , font = noto_sans_bold, color = (:black , 0.25 ))
88+
89+ label_a = fig[2 , 1 , TopLeft ()] = Label (fig, " A" , textsize = 24 ,
90+ font = noto_sans_bold, halign = :right )
91+ label_b = fig[2 , 3 , TopLeft ()] = Label (fig, " B" , textsize = 24 ,
92+ font = noto_sans_bold, halign = :right )
93+
94+ label_a. padding = (0 , 6 , 16 , 0 )
95+ label_b. padding = (0 , 6 , 16 , 0 )
96+
97+ # Aspect(1, 1) means that relative to row 1
98+ # (row because we're setting a colsize,
99+ # and aspect ratios are always about the other side)
100+ # we set the column to an aspect ratio of 1
101+
102+ colsize! (hm_sublayout, 1 , Aspect (1 , 1 ))
103+
104+ save (" layout_tutorial_final.svg" , fig)
105+ ```
106+
107+ ``` @raw html
108+ </details>
109+ ```
110+
13111All right, let's get started!
14112
15113## Importing a backend
0 commit comments