96 lines
2 KiB
Python
96 lines
2 KiB
Python
#!/bin/env -S python
|
|
|
|
from matplotlib import pyplot
|
|
from matplotlib.axes import Axes
|
|
from adjustText import adjust_text
|
|
|
|
|
|
from data import (pay, release)
|
|
|
|
|
|
def center(data: list[tuple[str, list[float]]], padding: float = 0):
|
|
for axis_index in range(len(data[0][1])):
|
|
min_ = min(data, key=lambda e: e[1][axis_index])[1][axis_index]
|
|
max_ = max(data, key=lambda e: e[1][axis_index])[1][axis_index]
|
|
delta = max_ - min_
|
|
desired_bias = (1 - padding)
|
|
desired_delta = 2 * desired_bias
|
|
for (_, values) in data:
|
|
original = values[axis_index]
|
|
value = (original - min_) / delta
|
|
value = (value * desired_delta) - desired_bias
|
|
values[axis_index] = value
|
|
|
|
|
|
to_rank = {
|
|
'c#',
|
|
'assembly',
|
|
'bash',
|
|
'basic',
|
|
'brainfuck',
|
|
'c',
|
|
'c++',
|
|
'cobol',
|
|
'css',
|
|
'dart',
|
|
'elixir',
|
|
'excel',
|
|
'fim++',
|
|
'fortran',
|
|
'go',
|
|
'haskell',
|
|
'java',
|
|
'javascript',
|
|
'jsfuck',
|
|
'julia',
|
|
'kotlin',
|
|
'lisp',
|
|
'lolcode',
|
|
'lua',
|
|
'matlab',
|
|
'objective-c',
|
|
'ocaml',
|
|
'perl',
|
|
'php',
|
|
'punch cards',
|
|
'python',
|
|
'r',
|
|
'redstone',
|
|
'ruby',
|
|
'rust',
|
|
'sass',
|
|
'scala',
|
|
'scratch',
|
|
'sql',
|
|
'swift',
|
|
'typescript',
|
|
'vb',
|
|
'wasm',
|
|
'whitespace',
|
|
'zsh',
|
|
}
|
|
|
|
|
|
ranked = list[tuple[str, list[float]]](
|
|
(label, [pay[label], release[label]])
|
|
for label in to_rank
|
|
if label in pay and label in release
|
|
)
|
|
center(ranked, 0.1)
|
|
|
|
|
|
print("\nunused", [l for l in pay.keys() if not l in map(lambda e: e[0], ranked)])
|
|
print("\nunused", [l for l in release.keys() if not l in map(lambda e: e[0], ranked)])
|
|
print("\nnot found", [l for l in to_rank if not l in map(lambda e: e[0], ranked)])
|
|
print("\nranked", ranked)
|
|
|
|
|
|
(figure, axes) = pyplot.subplots()
|
|
assert type(axes) is Axes
|
|
axes.plot([-1, 1], [0, 0])
|
|
axes.plot([0, 0], [-1, 1])
|
|
texts = [axes.text(p, r, l) for (l, [r, p]) in ranked]
|
|
adjust_text(texts, only_move={'points':'y', 'texts':'y'})
|
|
|
|
|
|
pyplot.show()
|