예제 #1
0
#server.main()
clear()


if __name__ == "__main__":

    import d3py
    
    if True:
        # line plot example
        T = 5*np.pi
        x = np.linspace(-T,T,100)
        colours = ["red","blue","green"]
        for a,c in zip([0.1, 0.2, 0.3], colours):
            y = np.exp(-a*x) * np.sin(x)
            d3py.line(x, y, xlabel="time", ylabel="value", color=c)
    
    if False:
        # histogram example
        d3py.histogram(np.random.standard_normal(1000), density=True)
    
    if False:
        # scatter example
        n = 400
        d1 = np.random.multivariate_normal([1,1], 0.5*np.eye(2), size=n)
        d2 = list(np.random.multivariate_normal([-1,-1], 2*np.eye(2), size=n))
        
        x = [d[0] for d in d1] + [d[0] for d in d2]
        y = [d[1] for d in d1] + [d[1] for d in d2]
        c = ["crimson" for i in range(n)] + ["green" for i in range(n)]
        d3py.scatter(x, y, c, xlabel="pigs", ylabel="cows")
예제 #2
0
파일: d3py.py 프로젝트: ewheeler/D3py
        webbrowser.open("http://localhost:7666/scatter", new=True)
    elif refresh == "manual":
        pass


if __name__ == "__main__":

    import d3py

    if False:
        # line plot example
        T = 5 * np.pi
        x = np.linspace(-T, T, 100)
        a = 0.05
        y = np.exp(-a * x) * np.sin(x)
        d3py.line(x, y, xlabel="time", ylabel="value")

    if False:
        # histogram example
        d3py.histogram(np.random.standard_normal(1000), density=True)

    if True:
        # scatter example
        n = 400
        d1 = np.random.multivariate_normal([1, 1], 0.5 * np.eye(2), size=n)
        d2 = list(np.random.multivariate_normal([-1, -1], 2 * np.eye(2), size=n))

        x = [d[0] for d in d1] + [d[0] for d in d2]
        y = [d[1] for d in d1] + [d[1] for d in d2]
        c = ["crimson" for i in range(n)] + ["green" for i in range(n)]
        d3py.scatter(x, y, c, xlabel="pigs", ylabel="cows")