Displaying plot of death rates from past years in Poland. Data source from these years is in readme

Overview

Average-Death-Rate

Displaying plot of death rates from past years in Poland


The goal

  1. collect the data from a CSV file
  2. count the ADR (Average Death Rate) from years 2015-2019 and 2020+
  3. change this data to float and add it into a list
  4. create a python data plot on which OX are the years and OY ADR data

Data source

Data source: death statistics from 1 september 2015


Demo Tests

Just to show how does matplotlib work:

In the real project, I will have two plots on one displayed interface. Those are divided into subplots, which in this case, there will be two of them.


The idea of the first plot. This data is from the actual source (not the one from my code).



Project source

Charts show data where data arrays are the same. First data array that goes on to OX should have the same length as data array on OY, so basically x = y without mentioning data types (except for str and bool). The few things to mention within the code in src directory are here just in case that you want it to work:



Debuggers

While checking if everything goes alright, I have used DBG's in my code and most of them are turned off. To turn them on, you can simply just change the DBG state:

    _DBG8_ = True                   # Other
    _DBG9_ = True                   # Standard debug

I have used _DBG9_ to check if class inside of count.py was giving the right answers. Around the class and programs inside of src directory, after each operation there is a debugger with an if. With a print() function, I could see if the operation was made correctly and at the same time, I was going on to the next line to see clearly if the next operation made was successful:

    if (_DBG9_): print('ls =', ls, '\n\n')



Screenshots and generating plots

All of these screenshots are made from a data science library to visualize data, matplotlib. On matplotlib, I set label of OX axis to 'Years' and OY axis to 'ADR'. Of course, the data for 'Years' and 'ADR' was generated within Operations() class inside of count.py file. Next, I needed to visualize the data on chart, so I used matplotlib plot function to show data on both, OX and OY axis and decorated them a bit by adding marker argument to plot function. I have also added a label to the graph:

    plt.title("ADR data chart from 2015")
    plt.xlabel('Years')         # OX label: years from 2015
    plt.ylabel('ADR')           # OY label: ADR (short: average death rate)


    # 2. adding plot:
    plt.plot(ls_years, ls_main_data, label='ADR', marker='o')      # OX data, OY data,

To show the label of main graph, you need to add the following function:

    plt.legend()

The final result:


The data should be displayed on two plots (or subplots). To do that, subplots() method was used for this. There are two subplots, and one column. To divide this into two rows and one column, the subplots() takes two arguments which describes the number of rows and columns:

    fig, ax = plt.subplots(nrows=row_num, ncols=col_num)

    figure, (axis0, axis1) = plt.subplots(nrows=2, ncols=1)      # In this project, this was made using these args

axis0 and axis1 are describing axis that the plot is on. Then for plot method, we don't use plt.plot(), label or titles because we assign different plots to different axis (in this case):

    figure, (axis0, axis1) = plt.subplots(nrows=2, ncols=1)

    axis0.set_title("ADR data charts 2015 - 2021")
    axis0.set_xlabel('Years')         # OX label: years from 2015
    axis0.set_ylabel('ADR')           # OY label: ADR (short: average death rate)

    axis0.plot(ls_years, ls_main_data, label='ADR', marker='o')      # OX data, OY data
    axis0.legend()
    axis0.grid(True)
    
    
    
    axis1.set_xlabel('Years (2020 - 2021+)')         # OX label: years from 2020
    axis1.set_ylabel('ADR')           # OY label: ADR (short: average death rate)

    axis1.plot(ls_second_years, ls_main_data[5:], label='ADR', marker='o', color='orange')
    axis1.legend()
    axis1.grid(True)
    
    plt.show()

At the end, we give plt.show() method because we want to display the whole data chart. The final result is here:

Updates:

03.09: adding standard deviation plot

Owner
Oliwier Szymański
self-taught coder. Most of my projects are written in Python or Java. I'm trying to learn from mistakes that I made in my codes and not only
Oliwier Szymański
Lightspin AWS IAM Vulnerability Scanner

Red-Shadow Lightspin AWS IAM Vulnerability Scanner Description Scan your AWS IAM Configuration for shadow admins in AWS IAM based on misconfigured den

Lightspin 90 Dec 14, 2022
Simple Python interface for Graphviz

Simple Python interface for Graphviz

Sebastian Bank 1.3k Dec 26, 2022
With Holoviews, your data visualizes itself.

HoloViews Stop plotting your data - annotate your data and let it visualize itself. HoloViews is an open-source Python library designed to make data a

HoloViz 2.3k Jan 04, 2023
A blender import/export system for Defold

defold-blender-export A Blender export system for the Defold game engine. Setup Notes There are no exhaustive documents for this tool yet. Its just no

David Lannan 27 Dec 30, 2022
Draw interactive NetworkX graphs with Altair

nx_altair Draw NetworkX graphs with Altair nx_altair offers a similar draw API to NetworkX but returns Altair Charts instead. If you'd like to contrib

Zachary Sailer 206 Dec 12, 2022
Typical: Fast, simple, & correct data-validation using Python 3 typing.

typical: Python's Typing Toolkit Introduction Typical is a library devoted to runtime analysis, inference, validation, and enforcement of Python types

Sean 171 Jan 02, 2023
Create Badges with stats of Scratch User, Project and Studio. Use those badges in Github readmes, etc.

Scratch-Stats-Badge Create customized Badges with stats of Scratch User, Studio or Project. Use those badges in Github readmes, etc. Examples Document

Siddhesh Chavan 5 Aug 28, 2022
Automate the case review on legal case documents and find the most critical cases using network analysis

Automation on Legal Court Cases Review This project is to automate the case review on legal case documents and find the most critical cases using netw

Yi Yin 7 Dec 28, 2022
I'm doing Genuary, an aritifiacilly generated month to build code that make beautiful things

Genuary 2022 I'm doing Genuary, an aritifiacilly generated month to build code that make beautiful things. Every day there is a new prompt for making

Joaquín Feltes 1 Jan 10, 2022
Boltzmann visualization - Visualize the Boltzmann distribution for simple quantum models of molecular motion

Boltzmann visualization - Visualize the Boltzmann distribution for simple quantum models of molecular motion

1 Jan 22, 2022
Python Package for CanvasXpress JS Visualization Tools

CanvasXpress Python Library About CanvasXpress for Python CanvasXpress was developed as the core visualization component for bioinformatics and system

Dr. Todd C. Brett 5 Nov 07, 2022
Numerical methods for ordinary differential equations: Euler, Improved Euler, Runge-Kutta.

Numerical methods Numerical methods for ordinary differential equations are methods used to find numerical approximations to the solutions of ordinary

Aleksey Korshuk 5 Apr 29, 2022
Python package to visualize and cluster partial dependence.

partial_dependence A python library for plotting partial dependence patterns of machine learning classifiers. The technique is a black box approach to

NYU Visualization Lab 25 Nov 14, 2022
erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes

erdantic is a simple tool for drawing entity relationship diagrams (ERDs) for Python data model classes. Diagrams are rendered using the venerable Graphviz library.

DrivenData 129 Jan 04, 2023
nptsne is a numpy compatible python binary package that offers a number of APIs for fast tSNE calculation.

nptsne nptsne is a numpy compatible python binary package that offers a number of APIs for fast tSNE calculation and HSNE modelling. For more detail s

Biomedical Visual Analytics Unit LUMC - TU Delft 29 Jul 05, 2022
Streamlit dashboard examples - Twitter cashtags, StockTwits, WSB, Charts, SQL Pattern Scanner

streamlit-dashboards Streamlit dashboard examples - Twitter cashtags, StockTwits, WSB, Charts, SQL Pattern Scanner Tutorial Video https://ww

122 Dec 21, 2022
Extract data from ThousandEyes REST API and visualize it on your customized Grafana Dashboard.

ThousandEyes Grafana Dashboard Extract data from the ThousandEyes REST API and visualize it on your customized Grafana Dashboard. Deploy Grafana, Infl

Flo Pachinger 16 Nov 26, 2022
Interactive Dashboard for Visualizing OSM Data Change

Dashboard and intuitive data downloader for more interactive experience with interpreting osm change data.

1 Feb 20, 2022
Info for The Great DataTas plot-a-thon

The Great DataTas plot-a-thon Datatas is organising a Data Visualisation competition: The Great DataTas plot-a-thon We will be using Tidy Tuesday data

2 Nov 21, 2021
Some problems of SSLC ( High School ) before outputs and after outputs

Some problems of SSLC ( High School ) before outputs and after outputs 1] A Python program and its output (output1) while running the program is given

Fayas Noushad 3 Dec 01, 2021