forked from Ravise/misc-scripts
Patch from Shadow
This commit is contained in:
parent
36573fe5a9
commit
4de345929c
@ -2,13 +2,12 @@ This folder deals with visualization of Haven's Post Office mailbox allocation.
|
||||
|
||||
Input: data.csv read from cwd. Expected format: x,y,z,owner (no header)
|
||||
|
||||
Output: YL-postoffice.png in user's home.
|
||||
Output: if given, file from $1 argument, or none
|
||||
|
||||
Improve:
|
||||
- labels should not overlap, arrows should point to mailboxes whereever annotation is out of mailbox bounds
|
||||
- walls should be displayed, as well as entrance orientation
|
||||
- fiddle with grid options
|
||||
- commandify/wheelify script
|
||||
|
||||
Requirements:
|
||||
- recent enough python (author used 3.10x64)
|
||||
|
@ -2,6 +2,7 @@ import csv
|
||||
import dataclasses
|
||||
import datetime
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
from matplotlib import patches
|
||||
from matplotlib import pyplot as plt
|
||||
@ -9,6 +10,9 @@ from matplotlib import pyplot as plt
|
||||
LOW = 13
|
||||
HIGH = 15
|
||||
|
||||
plt.rcParams["font.family"] = "monospace"
|
||||
plt.rcParams["font.monospace"] = ["IntelOne Mono"]
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Postbox:
|
||||
@ -40,10 +44,10 @@ for box in postboxes:
|
||||
if "#" in box.owner:
|
||||
continue
|
||||
|
||||
color = "green"
|
||||
color = "dimgrey"
|
||||
label = "Available"
|
||||
if box.owner:
|
||||
color = "red"
|
||||
color = "lightgrey"
|
||||
label = "Occupied"
|
||||
|
||||
offset = 0
|
||||
@ -63,29 +67,30 @@ for box in postboxes:
|
||||
texts.append(
|
||||
ax.annotate(
|
||||
box.owner,
|
||||
(box.x + 0.5, box.z + offset + 0.25),
|
||||
(box.x + 0.5, box.z + offset + 0.2),
|
||||
color="black",
|
||||
ha="center",
|
||||
va="center",
|
||||
fontvariant="small-caps",
|
||||
fontsize="small",
|
||||
fontsize=6,
|
||||
)
|
||||
)
|
||||
|
||||
ax.legend()
|
||||
|
||||
plt.grid(True)
|
||||
minx, minz = minx - 1, minz - 1
|
||||
maxx, maxz = maxx + 2, maxz + 2 # 1 from offset, 1 from rectangle width
|
||||
minx, minz = minx - 0.5, minz - 0.5
|
||||
maxx, maxz = maxx + 1.5, maxz + 1.5
|
||||
|
||||
ax.set_xlim(minx, maxx)
|
||||
ax.set_ylim(minz, maxz)
|
||||
ax.set_aspect(0.25)
|
||||
ax.set_aspect("auto")
|
||||
ax.set_title("Haven Post Office\n" + str(datetime.date.today()))
|
||||
plt.legend = ax.legend(handles=legend.values())
|
||||
plt.legend = ax.legend(handles=legend.values(), loc="center")
|
||||
|
||||
|
||||
fig.set_size_inches((22, 10))
|
||||
fig.savefig(pathlib.Path.home() / "YL-postoffice.png", dpi=144)
|
||||
fig.set_size_inches((31.25, 11.5))
|
||||
|
||||
plt.show()
|
||||
if len(sys.argv) >= 2:
|
||||
fig.savefig(pathlib.Path().absolute() / sys.argv[1], dpi=300)
|
||||
else:
|
||||
plt.show()
|
||||
|
Loading…
Reference in New Issue
Block a user