hugovk / pypi-tools

Command-line Python scripts to do things with PyPI
https://hugovk.github.io/pypi-tools
23 stars 2 forks source link

Add option to draw chart #2

Closed hugovk closed 6 years ago

hugovk commented 6 years ago

For example:

$ python jsons2csv.py -i "data/pillow*" --chart
data/pillow-2016-01.json 2016-01
data/pillow-2016-02.json 2016-02
data/pillow-2016-03.json 2016-03
data/pillow-2016-05.json 2016-05
data/pillow-2016-06.json 2016-06
data/pillow-2016-07.json 2016-07
data/pillow-2016-08.json 2016-08
data/pillow-2016-09.json 2016-09
data/pillow-2016-10.json 2016-10
data/pillow-2016-11.json 2016-11
data/pillow-2016-12.json 2016-12
data/pillow-2017-01.json 2017-01
data/pillow-2017-02.json 2017-02
data/pillow-2017-03.json 2017-03
data/pillow-2017-04.json 2017-04
data/pillow-2017-05.json 2017-05
data/pillow-2017-06.json 2017-06
data/pillow-2017-07.json 2017-07
data/pillow-2017-08.json 2017-08
data/pillow-2017-09.json 2017-09
data/pillow-2017-10.json 2017-10
data/pillow-2017-11.json 2017-11
data/pillow-2017-12.json 2017-12
data/pillow-2018-01.json 2018-01
data/pillow-2018-02.json 2018-02
data/pillow-2018-03.json 2018-03
data/pillow-2018-04.json 2018-04
data/pillow-2018-05.json 2018-05
data/pillow-2018-06.json 2018-06
data/pillow-2018-07.json 2018-07
{'2.6',
 '2.7',
 '2.8',
 '3.1',
 '3.2',
 '3.3',
 '3.4',
 '3.5',
 '3.6',
 '3.7',
 '3.8',
 'None'}
['#db4829', '#ecbf01', '#fc1737', '#6ae372', '#54c67a', '#a420bd', '#454481', '#dc0f04', '#463d33', '#f2a9c6', '#b87f7e', '#741e17']
pillow.png

pillow

hugovk commented 6 years ago

And uses the Dopplr hashing function to give unique colours for version numbers, so we always get the same colour for a version, even if we don't know what versions exactly we'll get for a given data set.

numpy

We wanted a deterministic RGB colour value for each city. At first, we tried mapping the latitude and longitude of a city to a point in colour space, but we found that this made neighbouring cities too similar in colour. This means that people who travel frequently between Glasgow and Edinburgh wouldn’t clearly see the difference in colour between the two. Also, since so much of the Earth’s surface is covered in water rather than cities, it leads to a sparse use of the potential colour space. In the end, we went with a much simpler approach: we take the MD5 digest of the city’s name, convert it to hex and take the first 6 characters as a CSS RGB value.

From the defunct Dopplr blog, saved by Ian Kennedy.

See also https://optional.is/required/2010/12/13/hls-world-map/ and https://optional.is/required/2011/01/12/maximum-color-contrast/.