-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexer5.py
30 lines (24 loc) · 778 Bytes
/
exer5.py
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
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = sns.load_dataset('tips')
print(df)
fig, ax = plt.subplots()
rects1 = ax.bar(df.total_bill, df.tip)
#ax.set_ylabel('Tip')
#ax.set_xlabel('Total Bill')
ax.set_title('Total Bill Vs Tip')
ax.set_xticks(df.total_bill)
ax.set_xticklabels(df.total_bill)
ax.legend()
def autolabel(rects):
"""Attach a text label above each bar in *rects*, displaying its height."""
for rect in rects:
height = rect.get_height()
ax.annotate('{}'.format(height),
xy=(rect.get_x(), height),
xytext=(0, 3), # 3 points vertical offset
textcoords="offset points",
ha='center', va='bottom')
autolabel(rects1)
plt.show()