def draw(self, ax=None, overlap=False, weight=False, cost=False): """ does all the plotting. Should be able to determine if we have terrain data etc. """ if not ax: #add a new one.. fig=plt.figure() ax=fig.add_subplot(111) ax=draw.plotBackground(globalOrigin=self.globalOrigin , areaPoly=self.areaPoly, ax=ax) ax=draw.plot2DContour(self.t_x,self.t_y,self.t_z,ax, w=2) draw.draw_custom(G=self, ax=ax, cost=cost,weight=weight, road_color='#01243B', road_width=4, poly=False) #bug in matplotlib always plots patch in back.. do line instead vertices=self.areaPoly+[self.areaPoly[0]] #closed x=[v[0] for v in vertices] y=[v[1] for v in vertices] l=Line2D(x,y, color='k', linewidth=4) ax.add_line(l) if overlap: draw.plot_coverage(self,ax, color='r') return ax
import requests import db import draw import util import config from money import Money, get_power, get_pivot if __name__ == '__main__': logging.basicConfig(level=logging.INFO) M = Money('_chf_m2_', 'CHF') M_tether = Money('tether', 'USD') M_btc = Money('bitcoin', 'BTC') tx_sqr = [(a[0], a[1]**2) for a in M.tx] tx_sqr_m = [(a[0], a[1] * (M.mcap[i][1] / M.mcap[0][1])) for i, a in enumerate(tx_sqr)] p = get_power(M.tx[-400:], M.mcap[0][1], M.mcap[-400:], M_btc.mcap[-400:]) tx_p = [(a[0], a[1]**p) for a in M.tx] tx_p_m = [(a[0], a[1] * (M.mcap[i][1] / M.mcap[0][1])) for i, a in enumerate(tx_p)] draw.draw_custom({ 'TX^{:.2f} M'.format(p): tx_p_m, '[:]TX^2 M': tx_sqr_m, 'Tether mcap (*10)': [(a[0], a[1]*10) for a in M_tether.mcap], 'CHF M2 mcap (/10)': [(a[0], a[1]/10) for a in M.mcap], 'BTC mcap': M_btc.mcap, })