rric

portrait_of_the_theatre

Dec 4th, 2023 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.48 KB | None | 0 0
  1. # Visualizes number of visitors and performances of Landestheater Linz,
  2. # inspired by Hermann Painitz' "Porträt der Neuen Galerie der Stadt Linz",
  3. # see virtual tour: https://tinyurl.com/lentos-3d-2021-Painitz
  4. # Copyright 2023 Roland Richter                          [Processing.py]
  5.  
  6. from __future__ import division, print_function
  7.  
  8.  
  9. # Data source: https://www.statistik.at/statistiken/bevoelkerung-und-soziales/kultur/theater-und-musik
  10. data = {
  11.     1981: {"season": "1980/81", "performances": 681, "visitors": 241611, },
  12.     1986: {"season": "1985/86", "performances": 659, "visitors": 208027, },
  13.     1991: {"season": "1990/91", "performances": 702, "visitors": 226105, },
  14.     1996: {"season": "1995/96", "performances": 725, "visitors": 233555, },
  15.     2001: {"season": "2000/01", "performances": 754, "visitors": 190443, },
  16.     2006: {"season": "2005/06", "performances": 903, "visitors": 234125, },
  17.     2011: {"season": "2010/11", "performances": 815, "visitors": 224886, },
  18.     2012: {"season": "2011/12", "performances": 794, "visitors": 226048, },
  19.     2013: {"season": "2012/13", "performances": 838, "visitors": 245188, },
  20.     2014: {"season": "2013/14", "performances": 878, "visitors": 322192, },
  21.     2015: {"season": "2014/15", "performances": 976, "visitors": 373654, },
  22.     2018: {"season": "2017/18", "performances": 840, "visitors": 306943, },
  23.     2019: {"season": "2018/19", "performances": 888, "visitors": 326298, },
  24.     2020: {"season": "2019/20", "performances": 572, "visitors": 200420, },
  25.     2021: {"season": "2020/21", "performances": 244, "visitors":  74437, }
  26. }
  27.  
  28.  
  29. def setup():
  30.     size(900, 500)
  31.    
  32.     textSize(18)
  33.     textAlign(CENTER, CENTER)
  34.    
  35.     # Determine the first and last year for which data is available
  36.     global first_year, last_year
  37.     first_year = sorted(data.keys())[0]
  38.     last_year = sorted(data.keys())[-1]
  39.    
  40.     # Find the minimum and maximum visitor count, ...
  41.     global min_visitors, max_visitors
  42.     min_visitors = max_visitors = data[first_year]["visitors"]
  43.  
  44.     for year in data.keys():
  45.         visitors = data[year]["visitors"]
  46.         if visitors < min_visitors:
  47.             min_visitors = visitors
  48.         if data[year]["visitors"] > max_visitors:
  49.             max_visitors = visitors
  50.  
  51.     # ... and the minimum and maximum performances count
  52.     global min_perfs, max_perfs
  53.     min_perfs = max_perfs = data[first_year]["performances"]
  54.    
  55.     for year in data.keys():
  56.         perfs = data[year]["performances"]
  57.    
  58.         if perfs < min_perfs:
  59.             min_perfs = perfs
  60.         if perfs > max_perfs:
  61.             max_perfs = perfs
  62.    
  63.  
  64. def draw():
  65.     background("#FFB7C5")   # background colour 'Cherry blossom pink'
  66.    
  67.     global first_year, last_year
  68.     global min_visitors, max_visitors, min_perfs, max_perfs
  69.    
  70.     for year in data.keys():
  71.         visitors = data[year]["visitors"]
  72.         performances = data[year]["performances"]
  73.        
  74.         # TRY to switch x and y here
  75.         x = map(performances, min_perfs, max_perfs, 0.05*width, 0.95*width)
  76.         y = map(year, first_year, last_year, 0.9*height, 0.1*height)
  77.        
  78.         # TRY to think of another way how to compute the diameter
  79.         diam = map(sqrt(visitors),
  80.                    sqrt(min_visitors), sqrt(max_visitors),
  81.                    0.1*mouseX, 0.5*mouseX)
  82.        
  83.         # QUIZ How do I visualize the number of performances and visitors?
  84.         # QUIZ Why do I use sqrt() -- the square root -- here?!
  85.  
  86.         fill(25, 25, 112, 128.0)   # 'Midnight blue' with opacity 50 %
  87.         circle(x, y, diam)
  88.        
  89.         if mousePressed:
  90.             fill(255)
  91.             text(data[year]["season"], x, y-18)
  92.             text(data[year]["performances"], x, y)
  93.             text(data[year]["visitors"], x, y+18)
  94.  
  95. # ----------------------------------------------------------------------
  96. # This program is free software: you can redistribute it and/or modify
  97. # it under the terms of the GNU General Public License as published by
  98. # the Free Software Foundation, either version 3 of the License, or
  99. # (at your option) any later version.
  100. #
  101. # This program is distributed in the hope that it will be useful,
  102. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  103. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  104. # GNU General Public License for more details.
  105. #
  106. # You should have received a copy of the GNU General Public License
  107. # along with this program.  If not, see <https://www.gnu.org/licenses/>.
Advertisement
Add Comment
Please, Sign In to add comment