import math
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.ticker import StrMethodFormatter as SMF
import pandas as pd
import seaborn as sns
#Create Data
data = pd.DataFrame(columns = ['Tenths',
'Hundreths',
'Profit'])
for h in range(0,10) :
for t in range(0,10) :
if (h == 0 & t ==0) :
p = 0
else :
#Dollar value of number is tenths and hundreths.
d = t/10 + h/100
#Reciprocal.
r = round(1/d, 2)
#Profit.
p = 100*d*r - 100
data = data.append({'Tenths' : t,
'Hundreths' : h,
'Profit' : p},
ignore_index = True)
data
Tenths | Hundreths | Profit | |
---|---|---|---|
0 | 0 | 0 | 0 |
1 | 1 | 0 | 0 |
2 | 2 | 0 | 0 |
3 | 3 | 0 | 0 |
4 | 4 | 0 | 0 |
... | ... | ... | ... |
95 | 5 | 9 | -0.29 |
96 | 6 | 9 | 0.05 |
97 | 7 | 9 | 0.33 |
98 | 8 | 9 | -0.32 |
99 | 9 | 9 | -0.01 |
100 rows × 3 columns
sns.set()
fig = plt.figure(figsize = (12.15, 10))
ax = fig.add_subplot(xlim = (-0.5, 9.5),
ylim = (-0.5, 9.5))
heatmap = plt.scatter(x = data['Tenths'],
y = data['Hundreths'],
c = data['Profit'],
cmap = 'RdBu',
marker = "s",
s = 2850)
#Title setup.
ax.set_title('Loss/Profit from Exchange Rate', fontsize = 24)
#X-axis setup.
ax.set_xlabel('Tenths Digit', fontsize = 22)
ax.set_xticks(range(0,10))
#Y-axis setup.
ax.set_ylabel('Hundreths Digit', fontsize = 22)
ax.set_yticks(range(0,10))
ax.tick_params(axis = 'both', which = 'major', labelsize = 18)
for row in data.iterrows():
plt.annotate(round(row[1][2], 2),
(row[1][0], row[1][1]),
c = "w",
fontsize = 22,
ha = "center",
va = "center")
#Colorbar.
plt.colorbar(heatmap).set_label('Loss/Profit', fontsize = 22);
fig.savefig("2023.05.26 Express.png",
bbox_inches = 'tight')