SHOW:
|
|
- or go back to the newest paste.
1 | import torch | |
2 | from torch import nn | |
3 | - | x=np.linspace(0,3,200) |
3 | + | from IPython.display import clear_output |
4 | - | Y=100*x |
4 | + | |
5 | - | y=(x<2)*(-(2-x)**2)*100/4+100 |
5 | + | |
6 | - | y2=np.ones_like(x)*100 |
6 | + | import math |
7 | - | img=plt.figure(figsize=(5,3.5)) |
7 | + | from math import pi |
8 | - | xlim=(0,3) |
8 | + | sampleX=torch.linspace(0,13,14) |
9 | - | ylim=(0,140) |
9 | + | sampleY=torch.zeros_like(sampleX) |
10 | - | origin=(0,0) |
10 | + | for i in range(14): |
11 | if(int(sampleX[i])%2==0):sampleY[i]=0.3 | |
12 | else:sampleY[i]=0.5 | |
13 | if(9<=sampleX[i] or sampleX[i]<0): | |
14 | sampleY[i]*=0.9 | |
15 | sampleY[i]+=0.2 | |
16 | sampleY*=100 | |
17 | testX=sampleX | |
18 | testY=sampleY | |
19 | img=plt.figure(figsize=(6.5,3)) | |
20 | - | plt.annotate(s="",xy=(xlim[1]+0.0005*(xlim[1]-origin[0]),origin[0]),xycoords="data",xytext=(-0.0001,0),textcoords="offset points",fontsize=12, |
20 | + | xlim=(0,14) |
21 | ylim=(20,70) | |
22 | - | plt.annotate(s="",xy=(origin[1],ylim[1]+0.0005*(ylim[1]-origin[1])),xycoords="data",xytext=(0,-0.0001),textcoords="offset points",fontsize=12, |
22 | + | origin=(0,20) |
23 | plt.xlim(xlim) | |
24 | - | ax.text(x=origin[0]+0.01*(xlim[1]-origin[0]),y=ylim[1]-0.01*(ylim[1]-origin[1]),s=r"$\alpha ($%$)$",fontsize=13) |
24 | + | |
25 | - | ax.text(y=origin[1]+0.03*(ylim[1]-origin[1]),x=xlim[1],s=r"$\frac{N'}{n}$",fontsize=17) |
25 | + | |
26 | - | plt.plot(x,y2,linestyle="--",color="black",linewidth=0.5) |
26 | + | |
27 | - | plt.plot([1,1],[0,100],linestyle="--",color="black",linewidth=0.5) |
27 | + | |
28 | - | plt.plot(x,Y,label="Consumer demand",linewidth=1.5) |
28 | + | |
29 | - | plt.plot(x,y,label="Socket usage",linewidth=1.5) |
29 | + | |
30 | - | plt.legend(loc="lower right") |
30 | + | |
31 | - | plt.annotate("Saturation of usage",xy=(2,100),xycoords="data",xytext=(0,-60),textcoords="offset points",fontsize=12, |
31 | + | |
32 | - | arrowprops=dict(arrowstyle='->',connectionstyle='arc3,rad=.2')) |
32 | + | x=np.linspace(0,13,14)+0.5 |
33 | - | x=1.2 |
33 | + | ticks=[] |
34 | - | y=(x<2)*(-(2-x)**2)*100/4+100 |
34 | + | for i in range(14): |
35 | - | Y=100*x |
35 | + | ticks.append(["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][int(i/2)]) |
36 | if(i%2==0):ticks[i]+="\nMorn" | |
37 | else:ticks[i]+="\nEve" | |
38 | plt.xticks(x,ticks,fontsize=12) | |
39 | plt.annotate(s="",xy=(xlim[1]+0.0005*(xlim[1]-xlim[0]),origin[1]),xycoords="data",xytext=(-0.0001,0),textcoords="offset points",fontsize=12, | |
40 | arrowprops=dict(arrowstyle='->')) | |
41 | plt.annotate(s="",xy=(origin[0],ylim[1]+0.0005*(ylim[1]-ylim[0])),xycoords="data",xytext=(0,-0.0001),textcoords="offset points",fontsize=12, | |
42 | arrowprops=dict(arrowstyle='->')) | |
43 | ax.text(x=origin[0]+0.01*(xlim[1]-origin[0]),y=ylim[1]-0.05*(ylim[1]-origin[1]),s=r"$\alpha($%$)$",fontsize=13) | |
44 | plt.bar(np.arange(14)+0.5,sampleY,facecolor="#9999ff",edgecolor="white") | |
45 | #plt.plot(sampleX,sampleY) | |
46 | plt.show() |