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)
|
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:
|
Improve:
|
||||||
- labels should not overlap, arrows should point to mailboxes whereever annotation is out of mailbox bounds
|
- 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
|
- walls should be displayed, as well as entrance orientation
|
||||||
- fiddle with grid options
|
- fiddle with grid options
|
||||||
- commandify/wheelify script
|
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
- recent enough python (author used 3.10x64)
|
- recent enough python (author used 3.10x64)
|
||||||
|
@ -2,6 +2,7 @@ import csv
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
import datetime
|
import datetime
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import sys
|
||||||
|
|
||||||
from matplotlib import patches
|
from matplotlib import patches
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
@ -9,6 +10,9 @@ from matplotlib import pyplot as plt
|
|||||||
LOW = 13
|
LOW = 13
|
||||||
HIGH = 15
|
HIGH = 15
|
||||||
|
|
||||||
|
plt.rcParams["font.family"] = "monospace"
|
||||||
|
plt.rcParams["font.monospace"] = ["IntelOne Mono"]
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class Postbox:
|
class Postbox:
|
||||||
@ -40,10 +44,10 @@ for box in postboxes:
|
|||||||
if "#" in box.owner:
|
if "#" in box.owner:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
color = "green"
|
color = "dimgrey"
|
||||||
label = "Available"
|
label = "Available"
|
||||||
if box.owner:
|
if box.owner:
|
||||||
color = "red"
|
color = "lightgrey"
|
||||||
label = "Occupied"
|
label = "Occupied"
|
||||||
|
|
||||||
offset = 0
|
offset = 0
|
||||||
@ -63,29 +67,30 @@ for box in postboxes:
|
|||||||
texts.append(
|
texts.append(
|
||||||
ax.annotate(
|
ax.annotate(
|
||||||
box.owner,
|
box.owner,
|
||||||
(box.x + 0.5, box.z + offset + 0.25),
|
(box.x + 0.5, box.z + offset + 0.2),
|
||||||
color="black",
|
color="black",
|
||||||
ha="center",
|
ha="center",
|
||||||
va="center",
|
va="center",
|
||||||
fontvariant="small-caps",
|
fontsize=6,
|
||||||
fontsize="small",
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
ax.legend()
|
ax.legend()
|
||||||
|
|
||||||
plt.grid(True)
|
plt.grid(True)
|
||||||
minx, minz = minx - 1, minz - 1
|
minx, minz = minx - 0.5, minz - 0.5
|
||||||
maxx, maxz = maxx + 2, maxz + 2 # 1 from offset, 1 from rectangle width
|
maxx, maxz = maxx + 1.5, maxz + 1.5
|
||||||
|
|
||||||
ax.set_xlim(minx, maxx)
|
ax.set_xlim(minx, maxx)
|
||||||
ax.set_ylim(minz, maxz)
|
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()))
|
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.set_size_inches((31.25, 11.5))
|
||||||
fig.savefig(pathlib.Path.home() / "YL-postoffice.png", dpi=144)
|
|
||||||
|
|
||||||
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