@@ -58,7 +58,8 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
58
58
# For each plot, the plot size is calculated by adding the space for the
59
59
# inner radius of each track.
60
60
index <- seq_along(plot_list )
61
- if (identical(circle @ direction , " outward" )) {
61
+ direction <- circle @ direction
62
+ if (identical(direction , " outward" )) {
62
63
plot_sizes <- radial $ inner_radius [1L ] / 0.4 + cumsum(plot_track )
63
64
} else {
64
65
plot_sizes <- 1 - cumsum(c(0 , plot_track [- length(plot_track )]))
@@ -132,6 +133,7 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
132
133
scales :: rescale(0.5 , from = bbox $ x ),
133
134
scales :: rescale(0.5 , from = bbox $ y )
134
135
)
136
+ spacing <- calc_element(" panel.spacing.r" , plot_theme )
135
137
136
138
if (is.null(plot_table )) {
137
139
plot_table <- gt
@@ -140,14 +142,17 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
140
142
rescale_factor <- last_plot_size / plot_size
141
143
142
144
# the spacer between two plots
143
- spacing <- calc_element(" panel.spacing.r" , plot_theme )
144
- if (inherits(spacing , " element_blank" ) || is.null(spacing )) {
145
- spacing <- unit(0 , " mm" )
145
+ if (identical(direction , " outward" )) {
146
+ spacer <- last_spacing
147
+ } else {
148
+ spacer <- spacing
149
+ }
150
+ if (inherits(spacer , " element_blank" ) || is.null(spacer )) {
151
+ spacer <- unit(0 , " mm" )
146
152
}
147
-
148
153
plot_table <- editGrob(plot_table , vp = viewport(
149
- width = unit(rescale_factor , " npc" ) - spacing ,
150
- height = unit(rescale_factor , " npc" ) - spacing ,
154
+ width = unit(rescale_factor , " npc" ) - spacer ,
155
+ height = unit(rescale_factor , " npc" ) - spacer ,
151
156
x = origin [1L ], y = origin [2L ], just = just ,
152
157
default.units = " native" , clip = " off"
153
158
))
@@ -186,6 +191,7 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
186
191
}
187
192
origin <- just
188
193
last_plot_size <- plot_size # the last plot panel size
194
+ last_spacing <- spacing
189
195
}
190
196
# attach the guide legends
191
197
guides <- lapply(c(.TLBR , " inside" ), function (guide_pos ) {
0 commit comments