Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Visualizes number of visitors and performances of Landestheater Linz,
- # inspired by Hermann Painitz' "Porträt der Neuen Galerie der Stadt Linz",
- # see virtual tour: https://tinyurl.com/lentos-3d-2021-Painitz
- # Copyright 2023 Roland Richter [Processing.py]
- from __future__ import division, print_function
- # Data source: https://www.statistik.at/statistiken/bevoelkerung-und-soziales/kultur/theater-und-musik
- data = {
- 1981: {"season": "1980/81", "performances": 681, "visitors": 241611, },
- 1986: {"season": "1985/86", "performances": 659, "visitors": 208027, },
- 1991: {"season": "1990/91", "performances": 702, "visitors": 226105, },
- 1996: {"season": "1995/96", "performances": 725, "visitors": 233555, },
- 2001: {"season": "2000/01", "performances": 754, "visitors": 190443, },
- 2006: {"season": "2005/06", "performances": 903, "visitors": 234125, },
- 2011: {"season": "2010/11", "performances": 815, "visitors": 224886, },
- 2012: {"season": "2011/12", "performances": 794, "visitors": 226048, },
- 2013: {"season": "2012/13", "performances": 838, "visitors": 245188, },
- 2014: {"season": "2013/14", "performances": 878, "visitors": 322192, },
- 2015: {"season": "2014/15", "performances": 976, "visitors": 373654, },
- 2018: {"season": "2017/18", "performances": 840, "visitors": 306943, },
- 2019: {"season": "2018/19", "performances": 888, "visitors": 326298, },
- 2020: {"season": "2019/20", "performances": 572, "visitors": 200420, },
- 2021: {"season": "2020/21", "performances": 244, "visitors": 74437, }
- }
- def setup():
- size(900, 500)
- textSize(18)
- textAlign(CENTER, CENTER)
- # Determine the first and last year for which data is available
- global first_year, last_year
- first_year = sorted(data.keys())[0]
- last_year = sorted(data.keys())[-1]
- # Find the minimum and maximum visitor count, ...
- global min_visitors, max_visitors
- min_visitors = max_visitors = data[first_year]["visitors"]
- for year in data.keys():
- visitors = data[year]["visitors"]
- if visitors < min_visitors:
- min_visitors = visitors
- if data[year]["visitors"] > max_visitors:
- max_visitors = visitors
- # ... and the minimum and maximum performances count
- global min_perfs, max_perfs
- min_perfs = max_perfs = data[first_year]["performances"]
- for year in data.keys():
- perfs = data[year]["performances"]
- if perfs < min_perfs:
- min_perfs = perfs
- if perfs > max_perfs:
- max_perfs = perfs
- def draw():
- background("#FFB7C5") # background colour 'Cherry blossom pink'
- global first_year, last_year
- global min_visitors, max_visitors, min_perfs, max_perfs
- for year in data.keys():
- visitors = data[year]["visitors"]
- performances = data[year]["performances"]
- # TRY to switch x and y here
- x = map(performances, min_perfs, max_perfs, 0.05*width, 0.95*width)
- y = map(year, first_year, last_year, 0.9*height, 0.1*height)
- # TRY to think of another way how to compute the diameter
- diam = map(sqrt(visitors),
- sqrt(min_visitors), sqrt(max_visitors),
- 0.1*mouseX, 0.5*mouseX)
- # QUIZ How do I visualize the number of performances and visitors?
- # QUIZ Why do I use sqrt() -- the square root -- here?!
- fill(25, 25, 112, 128.0) # 'Midnight blue' with opacity 50 %
- circle(x, y, diam)
- if mousePressed:
- fill(255)
- text(data[year]["season"], x, y-18)
- text(data[year]["performances"], x, y)
- text(data[year]["visitors"], x, y+18)
- # ----------------------------------------------------------------------
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
Advertisement
Add Comment
Please, Sign In to add comment