Commit 25760c1f authored by epsi sayidina's avatar epsi sayidina

note: python: matplotlib

parent 95fd52c6
import Text.Printf
-- penghasilan kena pajak
pkps :: [Int]
pkps = [0, 50, 250, 500, 10000]
-- kali sejuta
million :: [Int] -> [Int]
million nums = [ i * 10^6 | i <- nums ]
-- cetak
main = mapM_ (printf "%18d\n") (million pkps)
import numpy as np
import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt
def f(x):
return x**2 - 12*x - 64
x = np.arange(-6, 16, 0.2)
xdot = np.arange(-6, 16, 1)
plt.plot(x, f(x), 'k', xdot, f(xdot), 'bo')
plt.axis([-10, 20, -120, 60])
plt.axhline(y=0, color='k')
plt.axvline(x=0, color='k')
plt.grid()
plt.suptitle('Easy Quadratic Chart')
plt.title(r'$y = x^2 - 12x - 64$', fontsize=16, color='b', y=1.04)
plt.xlabel('Just X')
plt.ylabel('Just Y')
plt.show()
# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
def f(x, y):
return x**2 + y**2 - 12*x + 12*y + x*y - 64
# plot figure
fig = plt.figure()
ax = fig.gca(projection='3d')
# Make data.
X = np.arange(-5, 5.1, 0.2)
Y = np.arange(-5, 5.1, 0.2)
X, Y = np.meshgrid(X, Y)
Xline = np.arange(-5, 5.1, 1)
Yline = np.arange(-5, 5.1, 1)
Xline, Yline = np.meshgrid(Xline, Yline)
# Compute z to make the surface.
Z = f(X, Y)
Zline = f(Xline, Yline)
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.viridis,
linewidth=1, antialiased=False)
wire = ax.plot_wireframe(Xline, Yline, Zline)
# Customize the z axis.
ax.set_zlim(-151, 76)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)
# Make a 3D quiver plot
x, y, z = np.zeros((3,3))
u, v, w = np.array([[1,1,0],[1,0,1],[0,1,1]])
ax.quiver(x,y,z,u,v,w,arrow_length_ratio=0.1)
# Some decoration
plt.suptitle('Easy Quadratic Chart')
plt.xlabel('Just X')
plt.ylabel('Just Y')
ax.set_zlabel('Just Z', rotation=90)
# set z ticks
ax.set_zticks(np.arange(-150, 50, 25))
# latex
plt.title(r'$z = x^2 + y^2 - 12x + 12y + xy - 64$',
fontsize=16, color='b', y=1.06)
# finally
plt.show()
# penghasilan kena pajak
id_pkps = [0, 50, 250, 500, 1000]
id_pkps = [x * 10**6 for x in id_pkps]
for id_pkp in id_pkps:
print(f'Rp. {id_pkp:18,.2f}')
# penghasilan kena pajak
id_pkps = [0, 50, 250, 500, 1000]
id_pkps = [x * 10**6 for x in id_pkps]
# pajak penghasilan = tarif progresif pasal 17
[t1, t2, t3] = [x * 10**6 for x in [50, 250, 500]]
def pph(pkp):
if pkp <= t1:
return pkp * 0.05
elif pkp <= t2:
return (pkp - t1) * 0.15 + pph(t1)
elif pkp <= t3:
return (pkp - t2) * 0.25 + pph(t2)
else:
return (pkp - t3) * 0.30 + pph(t3)
for id_pkp in id_pkps:
id_pph = pph(id_pkp)
print(f'Rp. {id_pph:18,.2f}')
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
# pajak penghasilan = tarif progresif pasal 17
[t1, t2, t3] = [x * 10**6 for x in [50, 250, 500]]
def pph(pkp):
if pkp <= t1:
return pkp * 0.05
elif pkp <= t2:
return (pkp - t1) * 0.15 + pph(t1)
elif pkp <= t3:
return (pkp - t2) * 0.25 + pph(t2)
else:
return (pkp - t3) * 0.30 + pph(t3)
def currency(x, pos):
"""The two args are the value and tick position"""
if x >= 1e6:
s = 'Rp. {:1,.0f} juta'.format(x*1e-6)
else:
s = 'Rp. {:1,.0f} ribu'.format(x*1e-3)
return s
formatter = FuncFormatter(currency)
xs = np.arange(0, 6 * 10**8, 10**7)
xdots = np.arange(0, 6 * 10**8, 5*10**7)
ys = [pph(x) for x in xs]
ydots = [pph(xdot) for xdot in xdots]
plt.rcParams.update({'figure.autolayout': True})
fig, ax = plt.subplots()
ax.plot(xs, ys, 'k', xdots, ydots, 'bo')
ax.axis([0, 6 * 10**8, 0, 125 * 10**6])
plt.xticks(np.arange(0, 6 * 10**8 + 1 , 10**8))
plt.yticks(np.arange(0, 125 * 10**6 + 1, 2.5 * 10**7))
ax.axvline(x= 50 * 10**6, color='c')
ax.axhline(y= 2.5 * 10**6, color='c')
ax.axvline(x=250 * 10**6, color='m')
ax.axhline(y=32.5 * 10**6, color='m')
ax.axvline(x=500 * 10**6, color='y')
ax.axhline(y= 95 * 10**6, color='y')
ax.grid()
labels = ax.get_xticklabels()
plt.setp(labels,
rotation=45,
horizontalalignment='right')
ax.set(title='Tarif Progresif PPh 21',
xlabel='PKP', ylabel='PPh')
ax.xaxis.label.set_size(16)
ax.yaxis.label.set_size(16)
ax.title.set_size(20)
ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)
plt.show()
\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
$\displaystyle
PPh\,21(n) =
\begin{cases}
5\%\,n_{1} & n \leq 50\,juta \\
+ 15\%\,n_{2} & 50\,juta < n \leq 250\,juta \\
+ 25\%\,n_{3} & 250\,juta < n \leq 500\,juta \\
+ 30\%\,n_{4} & n > 500\,juta
\end{cases}
$
\end{document}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment