示例#1
0
def stockplotter(tickerlist, colorlist, intervalsel):
    fig = plt.gca(projection='3d')
    numstocks = len(tickerlist)
    maxy = 0
    miny = 0
    verts = getstockslist(tickerlist, intervalsel)
    for x in range(len(verts)):
        for y in range(len(verts[x])):
            if verts[x][y][1] > maxy:
                maxy = verts[x][y][1]
            if verts[x][y][1] < miny:
                miny = verts[x][y][1]
    customlegend = []
    for x in range(numstocks):
        customlegend.append(
            mpatches.Patch(color=colorlist[x], label=tickerlist[x].upper()))
    fig.legend(handles=customlegend)
    zs = np.arange(0, numstocks, 1.0)
    poly = PolyCollection(verts,
                          facecolors=colorlist[0:numstocks],
                          lw=0.5,
                          edgecolor=(0, 0, 0, 1))
    poly.set_alpha(0.5)
    poly.set_linestyle(ls='-')
    poly.set_linewidth(lw=2.0)
    fig.add_collection3d(poly, zs=zs, zdir='y')
    if intervalsel == '7d':
        fig.set_xlim3d(0, 7)
        fig.set_xlabel("Time (day)")
        fig.set_zlabel("Price increase since start of week(%)")
    else:
        fig.set_xlim3d(0, len(verts[0]))
        if intervalsel == '1mo':
            fig.set_xlabel("Time (hr)")
            fig.set_zlabel("Price increase in last month(%)")
        if intervalsel == '1y':
            fig.set_xlabel("Time (day)")
            fig.set_zlabel("Price increase in last year(%)")
    #to change when understand
    fig.set_ylabel("Stock")
    fig.set_ylim3d(0, numstocks)  #set to number of stocks
    fig.set_zlim3d(miny, maxy)
    plt.show()
    plt.close('all')
示例#2
0
    0.0029092716847696, 0.00356688706734209, 0.00479077379901016,
    0.00685504146621263, 0.0125617481538253, 0.0328812131141895,
    0.098875134437398, 0.17861702662974, 0.20581123651118, 0.158502290327443,
    0.10979557830891, 0.0433181749174081, 0.0127110651278319,
    0.00262555547231493
]

fig = plt.figure()
ax = fig.gca(projection='3d')

verts = []
for i in range(0, 7):
    verts.append(list(zip(np.array(ens[i]), np.array(ps[i]))))

poly = PolyCollection(verts)
poly.set_alpha(0.6)
poly.set_linestyle('-')
poly.set_edgecolor('k')
ax.add_collection3d(poly, zs=angles, zdir='y')

maxEn = max(max(ens))

ax.set_ylabel('cosine', fontsize=12)
ax.set_ylim3d(-1, 1)
ax.set_zlabel('probability/eV', fontsize=12)
ax.set_zlim3d(0, 0.25)
ax.set_xlabel('energy(Mev)', fontsize=12)
ax.set_xlim3d(0.1, maxEn + maxEn * 0.1)
plt.savefig(f"spectrum.png", dpi=1200)
#plt.show()