Note
Go to the end to download the full example code.
Wikipedia
Demonstrating some style options with the Simple-Wikipedia Data map

Calculating medoids: 0%| | 0/50 [00:00<?, ?it/s]
Calculating medoids: 2%|▏ | 1/50 [00:05<04:29, 5.49s/it]
Calculating medoids: 22%|██▏ | 11/50 [00:05<00:14, 2.71it/s]
Calculating medoids: 42%|████▏ | 21/50 [00:05<00:04, 6.09it/s]
Calculating medoids: 62%|██████▏ | 31/50 [00:05<00:01, 10.52it/s]
Calculating medoids: 82%|████████▏ | 41/50 [00:05<00:00, 16.14it/s]
Calculating medoids: 100%|██████████| 50/50 [00:06<00:00, 8.32it/s]
import datamapplot
import numpy as np
import requests
import PIL
import matplotlib.pyplot as plt
plt.rcParams['savefig.bbox'] = 'tight'
wikipedia_data_map = np.load("Wikipedia-data_map.npz")["arr_0"]
wikipedia_labels = np.load("Wikipedia-cluster_labels.npz", allow_pickle=True)["arr_0"]
cohere_logo_response = requests.get(
"https://asset.brandfetch.io/idfDTLvPCK/idyv4d98RT.png",
stream=True,
)
cohere_logo = np.asarray(PIL.Image.open(cohere_logo_response.raw).convert("RGBA"))
fig, ax = datamapplot.create_plot(
wikipedia_data_map,
wikipedia_labels,
title="Map of Wikipedia",
sub_title="Paragraphs from articles on Simple Wikipedia embedded with Cohere embed",
logo=cohere_logo,
logo_width=0.28,
use_medoids=True,
arrowprops={"arrowstyle": "wedge,tail_width=0.85,shrink_factor=0.15", "linewidth": 0.4, "fc": "#33333377", "ec": "#333333aa"},
font_family="Marcellus SC",
label_linespacing=1.25,
label_direction_bias=1.25,
title_keywords={"fontsize":62.5}
)
ax.set(facecolor="#eae6de")
fig.savefig("plot_wikipedia.png", bbox_inches="tight")
plt.show()
Total running time of the script: (0 minutes 32.366 seconds)