Skip to content

Commit ca5d8f0

Browse files
author
Leonard Poon
committed
- updated R code for plotting
1 parent 9eef65f commit ca5d8f0

File tree

2 files changed

+117
-6
lines changed

2 files changed

+117
-6
lines changed

R/conf.R

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
conf.data <- read.csv("aaai_ijcai.20160505.conference.csv", sep="\t", quote="")
23

34
plot.conf <- function(topic) {
@@ -8,7 +9,41 @@ plot.conf <- function(topic) {
89

910
filename <- paste(topic, ".conf.pdf", sep="")
1011
quartz(topic, width=5, height=3)
11-
barplot(values, xlab="Documents (%)", horiz=TRUE)
12+
barplot(values, xlab="Documents (%)", horiz=TRUE, col=c("red","blue"))
1213
quartz.save(filename, type="pdf")
1314
}
1415

16+
topics.l7 <- as.character(conf.data[conf.data$level==7,]$name)
17+
18+
plot.conf.multiple <- function(topics, order=TRUE) {
19+
values <- conf.data[topics,]$phi..ijcai
20+
names(values) <- conf.data[topics,]$words
21+
22+
if (order) {
23+
values <- values[order(values)]
24+
}
25+
26+
ii <- cut(values, breaks = seq(min(values), max(values), len = 20),
27+
include.lowest = TRUE)
28+
## Use bin indices, ii, to select color from vector of n-1 equally spaced colors
29+
colors <- colorRampPalette(c("red", "blue"))(20)[ii]
30+
31+
## col <- colorRampPalette(c("red", "blue"))
32+
## colors <- colvalues
33+
quartz(width=8,height=5)
34+
opar <- par(no.readonly=TRUE)
35+
par(mar=c(3.5,1,0.1,30), cex.axis=0.75)
36+
mp <- barplot(values, horiz=TRUE,
37+
xlim=c(-0.2,0.2), space=1,yaxt="n",
38+
col=colors)
39+
axis(4, at=mp, labels=names(values), las=2, tick=FALSE)
40+
mtext("IJCAI", side=1, line=2, adj=1, col="blue")
41+
mtext("AAAI", side=1, line=2, adj=0, col="red")
42+
par(opar)
43+
}
44+
45+
plot.conf.separate <- function(topics) {
46+
for (t in topics) {
47+
plot.conf(t)
48+
}
49+
}

R/year.R

+81-5
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,91 @@ plot.years <- function(topic) {
131131
plot(compute.fraction(topic))
132132
}
133133

134-
plot.fraction.years <- function(topic) {
135-
quartz(title=topic, width=5, height=5)
134+
plot.fraction.years <- function(topic, new=TRUE, use.words=FALSE, ylim=50) {
135+
if (use.words)
136+
title <- topics[topics$name==topic,]$words
137+
else
138+
title <- topic
139+
140+
141+
if (new)
142+
quartz(title=title, width=5, height=5)
143+
136144
m <- compute.fraction.matrix(topic)
137145

138146
## convert to percentage
139147
m[,2] <- m[,2] * 100
140148

141149
plot(m[,1], m[,2], pch=16, col="blue",
142-
main=topic, ylab="Documents (%)", xlab="Year", ylim=c(0,50))
143-
abline(lm(fraction ~ year, as.data.frame(m)))
150+
main=title, ylab="Documents (%)", xlab="Year", ylim=c(0,ylim))
151+
abline(lm(fraction ~ year, as.data.frame(m)), col=gray(0.5))
152+
153+
if (new) {
154+
filename <- paste(topic, "-trend.pdf", sep="")
155+
quartz.save(filename, type="pdf")
156+
}
157+
}
158+
159+
plot.years.separate <- function(topics) {
160+
for (t in topics) {
161+
plot.fraction.years(t)
162+
}
163+
}
164+
165+
run <- function() {
166+
plot.fraction.years("Z1321", ylim=12)
167+
plot.fraction.years("Z1327", ylim=10)
168+
plot.fraction.years("Z1315", ylim=8)
169+
plot.fraction.years("Z12311", ylim=12)
170+
plot.fraction.years("Z13032", ylim=10)
171+
plot.fraction.years("Z2995", ylim=8)
172+
}
173+
174+
plot.downward <- function() {
175+
yl <- 15
176+
plot.fraction.years("Z3159", ylim=yl)
177+
plot.fraction.years("Z3384", ylim=yl)
178+
plot.fraction.years("Z3302", ylim=yl)
179+
plot.fraction.years("Z3192", ylim=yl)
180+
plot.fraction.years("Z3158", ylim=yl)
181+
}
182+
183+
plot.upward <- function() {
184+
yl <- 15
185+
plot.fraction.years("Z370", ylim=yl)
186+
plot.fraction.years("Z344", ylim=yl)
187+
plot.fraction.years("Z3207", ylim=yl)
188+
plot.fraction.years("Z326", ylim=yl)
189+
plot.fraction.years("Z3204", ylim=yl)
190+
}
191+
192+
193+
plot.toplevel.years <- function() {
194+
plot.topic.years(c("Z77", "Z72", "Z79", "Z711", "Z73", "Z74", "Z71",
195+
"Z713", "Z76", "Z712", "Z75", "Z78", "Z710"),
196+
TRUE)
197+
}
198+
199+
plot.topic.years <- function(ts, use.words=FALSE) {
200+
quartz(title="Topic Trend", width=15, height=9)
201+
202+
nrows <- ceiling(length(ts) / 5)
203+
opar <- par(no.readonly=TRUE)
204+
par(mfrow=c(nrows, 5), mar=c(2,2,2,1))
205+
206+
for (topic in ts) {
207+
m <- compute.fraction.matrix(topic)
208+
words <- topics[topics$name==topic,]$words
209+
210+
## convert to percentage
211+
m[,2] <- m[,2] * 100
212+
213+
plot(m[,1], m[,2], pch=16, col="blue",
214+
ylim=c(0,50),ann=FALSE)
215+
abline(lm(fraction ~ year, as.data.frame(m)), col=gray(0.5))
216+
title(main=topic)
217+
}
218+
par(opar)
144219
}
145220

146221
## Computes regression coefficients for topics. The data is saved if a filename
@@ -152,7 +227,8 @@ compute.coefficients <- function(filename=NULL, topics.selected=NULL) {
152227
coefficients <- find.coefficients(topics.selected)
153228
lines <- fit.fraction.lm.topics(topics.selected)
154229

155-
indices <- sapply(rownames(coefficients), function(t) { which(topics$name==t) })
230+
indices <- sapply(rownames(coefficients),
231+
function(t) { which(topics$name==t) })
156232
data <- cbind(topics[indices,], coefficients, lines)
157233

158234
if (!is.null(filename)) {

0 commit comments

Comments
 (0)