diff --git a/main.py b/main.py new file mode 100644 index 0000000..9f1fc4b --- /dev/null +++ b/main.py @@ -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() diff --git a/plot.png b/plot.png new file mode 100644 index 0000000..234a58e Binary files /dev/null and b/plot.png differ diff --git a/solution_.md b/solution_.md new file mode 100644 index 0000000..d1d5a3c --- /dev/null +++ b/solution_.md @@ -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)