forked from gzavo/CS_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
36 lines (32 loc) · 1.04 KB
/
Copy pathplot.py
File metadata and controls
36 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pandas as pd
from matplotlib import pyplot as plt
from tabulate import tabulate
plt.rcParams["figure.autolayout"] = True
plt.rcParams['figure.dpi'] = 300
df = pd.read_csv("istherecorrelation.csv")
# displaying the DataFrame
print(tabulate(df, headers = 'keys', tablefmt = 'psql'))
# create figure and axis objects with subplots()
fig,ax = plt.subplots()
# make a plot
ax.plot(df["Year"],
df["WO [x1000]"],
color="red",
marker="o")
# set x-axis label
ax.set_xlabel("year", fontsize = 14)
# set y-axis label
ax.set_ylabel("WO [x1000]",
color="red",
fontsize=6)
# twin object for two different y-axis on the sample plot
ax2=ax.twinx()
# make a plot with different y-axis using second axis object
ax2.plot(df["Year"], df["NL Beer consumption [x1000 hectoliter]"],color="blue",marker="o")
ax2.set_ylabel("NL Beer consumption [x1000 hectoliter]",color="blue",fontsize=6)
plt.show()
# save the plot as a file
fig.savefig('plot.png',
format='jpeg',
dpi=300,
bbox_inches='tight')