Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solutions for the assignment #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import matplotlib.pyplot as plt

def main():

# Extract data from csv file using 'utf-8-sig' encoding, this removes
# the strange characters at the start of the csv.
# https://stackoverflow.com/questions/34399172/why-does-my-python-code-print-the-extra-characters-%C3%AF-when-reading-from-a-tex/34399309
with open("istherecorrelation.csv", encoding="utf-8-sig") as f:

header = f.readline().strip().split(";")

data = [row.strip().split(";") for row in f]

# Store each column in a seperate list and convert the data type
years = [int(row[0]) for row in data]
wo = [float(row[1].replace(",", ".")) for row in data]
beer_consumption = [float(row[2]) for row in data]

fig, ax = plt.subplots()

ax.set_xlabel(header[0])

ax.plot(years, wo, '-ro', label=header[1])
ax.set_ylabel(header[1])

# Create a secondary y axis
ax2 = ax.twinx()
ax2.plot(years, beer_consumption, '-bo', label=header[2])
ax2.set_ylabel(header[2])

fig.legend()

# Increase the figure size, such that the second yaxis label can be read
fig.set_size_inches(10, 6)

fig.savefig("plot.png", dpi=300)
plt.show()


if __name__ == "__main__":
main()
Binary file added plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions solution_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Solution
Nick van Santen, 11857846

The title of the three papers are:
- Fantastic yeasts and where to find them: the hidden diversity of dimorphic fungal pathogens
- An analysis of the forces required to drag sheep over various surfaces
- Correlation of continuous cardiac output measured by a pulmonary artery catheter versus impedance cardiography in ventilated patients

The following plot shows the number of university students on one axis and the consumption of beer on the other axis. There appears to be a correlation between the two, however, the data on itself is not enough to directly relate the two data sets.
![plot of istherecorrelation.csv](plot.png)