-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_world_example.py
64 lines (48 loc) · 1.32 KB
/
plot_world_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 8 17:52:12 2022
@author: jam
"""
#%% global packages
import sys
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.colors as colors
import matplotlib.figure as figure
mpl.rc('text', usetex=True)
mpl.rc('font', family='serif')
mpl.rc('font', size=10)
from IPython.core.display import display
#%%
world_size = 64
if len (sys.argv) > 1:
world_name = sys.argv[1]
else:
world_name = 'world_size{}_init50_sync_detr_dp2_st7.csv'.format(world_size)
data = pd.read_csv("" + world_name + '',
skiprows=15,
nrows=world_size*world_size,
usecols = ["pcolor"]
)
data = data.to_numpy()
data = np.reshape(data,(world_size,world_size))
#%%
fig = mpl.figure.Figure(figsize=(6, 5.5))
axs = fig.add_subplot(111)
#%%
axs.matshow(data, cmap=colors.ListedColormap(["black", 'white']))
axs.spines['top'].set_visible(False)
axs.spines['right'].set_visible(False)
axs.spines['bottom'].set_visible(False)
axs.spines['left'].set_visible(False)
axs.set_xticks([])
axs.set_yticks([])
axs.margins()
#%%
fig.tight_layout()
display(fig)
fName = "plots/plot_" + world_name.replace(".csv","") + ".pdf"
print("[INFO] Saving " + fName)
fig.savefig(fName, format="pdf", bbox_inches='tight')