d = as_embed(demodata, normalize=TRUE)
dt = get_wordvec(d, cc("
man, woman,
king, queen,
China, Beijing,
Japan, Tokyo"))
## 2-D (default):
plot_wordvec_tSNE(dt, seed=1234)
plot_wordvec_tSNE(dt, seed=1234)$data
colors = c(rep("#2B579A", 4), rep("#B7472A", 4))
plot_wordvec_tSNE(dt, colors=colors, seed=1234)
category = c(rep("gender", 4), rep("country", 4))
plot_wordvec_tSNE(dt, colors=category, seed=1234) +
scale_x_continuous(limits=c(-200, 200),
labels=function(x) x/100) +
scale_y_continuous(limits=c(-200, 200),
labels=function(x) x/100) +
scale_color_manual(values=c("#B7472A", "#2B579A"))
## 3-D:
colors = c(rep("#2B579A", 4), rep("#B7472A", 4))
plot_wordvec_tSNE(dt, dims=3, colors=colors, seed=1)
Run the code above in your browser using DataLab