Skip to content

Commit a55e3e7

Browse files
committed
fixed minor bugs
1 parent ea2eeb1 commit a55e3e7

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/common/plots/_plot_misc.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,28 @@ draw.volume.rects <- function(ylim, volume.stats, narr.unit)
2323
{ # rectangle colors
2424
rec.pal <- c("gray90","gray80")
2525

26+
# identify appropriate columns
2627
if(narr.unit=="scene")
2728
{ start.col <- COL_SCENE_START_ID
2829
end.col <- COL_SCENE_END_ID
2930
}
30-
else if(narr.unit=="narr.unit")
31+
else if(narr.unit=="chapter")
3132
{ start.col <- COL_CHAPTER_START_ID
3233
end.col <- COL_CHAPTER_END_ID
3334
}
3435

36+
# compute x rectangle bounds
37+
bounds.x <- c(
38+
1,
39+
(volume.stats[1:(nrow(volume.stats)-1),end.col] + volume.stats[2:nrow(volume.stats),start.col])/2,
40+
volume.stats[nrow(volume.stats),end.col]
41+
)
3542
# draw each volume
3643
for(v in 1:nrow(volume.stats))
3744
{ rect(
38-
xleft=volume.stats[v,start.col],
39-
xright=volume.stats[v,end.col],
40-
ybottom=ylim[1]-abs(ylim[1])*0.05,
45+
xleft=bounds.x[v],
46+
xright=bounds.x[v+1],
47+
ybottom=ylim[1]-(ylim[2]-ylim[1])*0.05,
4148
ytop=ylim[2],
4249
col=rec.pal[(v %% 2)+1],
4350
border=NA, density=NA

src/dynamic/evol_prop.R

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ evol.prop.graph <- function(gg, volume.stats, net.type, filtered, pub.order, plo
2727
{ tlog(2, "Computing the graph measures")
2828
filt.txt <- if(filtered) "filtered" else "unfiltered"
2929
sc.nbr <- length(gg)
30+
3031
narr.unit <- strsplit(gg[[1]]$NarrUnit, split="_")[[1]][1]
32+
# handle narrative unit
33+
if(narr.unit %in% c("volume","arc"))
34+
plot.vols <- FALSE
35+
narr.unit.map <- c(scene="Scenes", chapter="Chapters", volume="Volumes", arc="Arcs")
3136

3237
# order volumes
3338
if(pub.order) # by publication order
@@ -146,15 +151,15 @@ evol.prop.graph <- function(gg, volume.stats, net.type, filtered, pub.order, plo
146151
# ylim=GRAPH_MEASURES[[meas]]$bounds,
147152
xlim=c(1,sc.nbr), ylim=ylim,
148153
log=if(meas %in% log.y) "y" else "",
149-
xlab="Scenes", ylab=GRAPH_MEASURES[[meas]]$cname
154+
xlab=narr.unit.map[narr.unit], ylab=GRAPH_MEASURES[[meas]]$cname
150155
)
151156
# possibly add volume representations
152157
if(plot.vols)
153158
draw.volume.rects(ylim, volume.stats[ord.vols,], narr.unit=narr.unit)
154159
# add line
155160
lines(
156161
x=1:sc.nbr, y=vals,
157-
#xlab="Scenes", ylab=GRAPH_MEASURES[[meas]]$cname,
162+
#xlab=narr.unit.map[narr.unit], ylab=GRAPH_MEASURES[[meas]]$cname,
158163
col=col
159164
)
160165
# close file
@@ -191,7 +196,12 @@ evol.prop.vertices <- function(gg, vtx.plot, char.stats, volume.stats, net.type,
191196
tlog(2, "Computing the vertex measures")
192197
filt.txt <- if(filtered) "filtered" else "unfiltered"
193198
sc.nbr <- length(gg)
199+
200+
# handle narrative unit
194201
narr.unit <- strsplit(gg[[1]]$NarrUnit, split="_")[[1]][1]
202+
if(narr.unit %in% c("volume","arc"))
203+
plot.vols <- FALSE
204+
narr.unit.map <- c(scene="Scenes", chapter="Chapters", volume="Volumes", arc="Arcs")
195205

196206
# character names
197207
char.names <- data$char.stats[,COL_NAME]
@@ -308,7 +318,7 @@ evol.prop.vertices <- function(gg, vtx.plot, char.stats, volume.stats, net.type,
308318
NULL,
309319
ylim=ylim, xlim=c(1,sc.nbr),
310320
log=if(meas %in% log.y) "y" else "",
311-
xlab="Scenes", ylab=NODE_MEASURES[[meas]]$cname
321+
xlab=narr.unit.map[narr.unit], ylab=NODE_MEASURES[[meas]]$cname
312322
)
313323
# possibly add volume representations
314324
if(plot.vols)
@@ -361,6 +371,7 @@ evol.prop.edges <- function(gg, vtx.plot, char.stats, volume.stats, net.type, fi
361371
narr.unit <- strsplit(gg[[1]]$NarrUnit, split="_")[[1]][1]
362372
if(narr.unit %in% c("volume","arc"))
363373
plot.vols <- FALSE
374+
narr.unit.map <- c(scene="Scenes", chapter="Chapters", volume="Volumes", arc="Arcs")
364375

365376
# character names
366377
char.names <- data$char.stats[,COL_NAME]
@@ -487,7 +498,7 @@ evol.prop.edges <- function(gg, vtx.plot, char.stats, volume.stats, net.type, fi
487498
NULL,
488499
ylim=ylim, xlim=c(1,sc.nbr),
489500
log=if(meas %in% log.y) "y" else "",
490-
xlab="Scenes", ylab=LINK_MEASURES[[meas]]$cname
501+
xlab=narr.unit.map[narr.unit], ylab=LINK_MEASURES[[meas]]$cname
491502
)
492503
# possibly add volume representations
493504
if(plot.vols)

0 commit comments

Comments
 (0)