Пример #1
0
def plot3d(gridi):

    from mpl_toolkits.mplot3d import axes3d
    import matplotlib.pyplot as plt
    from matplotlib import cm

    fig = plt.figure()
    ax = fig.gca(projection="3d")
    X, Y, Z = axes3d.get_test_data(0.05)
    print "axes3d.get_test_data(0.05)", list(axes3d.get_test_data(0.05)).shape
    cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)
    ax.clabel(cset, fontsize=9, inline=1)

    plt.show()
Пример #2
0
def contourf_demo(**kwargs):
    import mpl_toolkits.mplot3d.axes3d as axes3d
    from ifigure.interactive import contourf, threed, figure
    X, Y, Z = axes3d.get_test_data(0.05) 
    v = figure(gl = True)
    threed('on')
    contourf(X, Y, Z)
Пример #3
0
def show3D():
    # imports specific to the plots in this example
    import numpy as np
    from matplotlib import cm
    from mpl_toolkits.mplot3d.axes3d import get_test_data
    
    # Twice as wide as it is tall.
    fig = plt.figure(figsize=plt.figaspect(0.5))
    
    #---- First subplot
    ax = fig.add_subplot(1, 2, 1, projection='3d')
    X = np.arange(-5, 5, 0.1)
    Y = np.arange(-5, 5, 0.1)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
            linewidth=0, antialiased=False)
    ax.set_zlim3d(-1.01, 1.01)
    
    fig.colorbar(surf, shrink=0.5, aspect=10)
    
    #---- Second subplot
    ax = fig.add_subplot(1, 2, 2, projection='3d')
    X, Y, Z = get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

    mystyle.printout_plain('3dGraph.png')
Пример #4
0
def test():
    # Twice as wide as it is tall.
    fig = plt.figure(figsize=plt.figaspect(0.5))

    #---- First subplot
    ax = fig.add_subplot(1, 2, 1, projection='3d')
    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)
    print type(X)
    print X.shape
    print Y.shape
    print Z.shape
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
            linewidth=0, antialiased=False)
    ax.set_zlim3d(-1.01, 1.01)

    fig.colorbar(surf, shrink=0.5, aspect=10)

    #---- Second subplot
    ax = fig.add_subplot(1, 2, 2, projection='3d')
    X, Y, Z = get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

    plt.show()
Пример #5
0
        def __init__(self, parent, title):
            wx.Frame.__init__(self, parent, title=title, size=(1024, 768))

            Notebook = wx.Notebook(self)

            plot1 = plot(Notebook)
            x_data = [1, 2, 3, 4, 5, 6]
            y_data = npy.random.random(6)
            data = npy.column_stack((x_data, y_data))
            plot1.plot_2d(data, x_column=0, y_column=1, title="test 2d plot")
            Notebook.AddPage(plot1, "2d plot - random data")

            plot2 = plot(Notebook)
            # 3d plot example - grab dummy data from mpl
            from mpl_toolkits.mplot3d import axes3d

            # discard X and Y data - we will provide coverage when we call plot_3d
            X, Y, Z = axes3d.get_test_data(0.5)
            plot2.plot_3d(title="test 3d plot", z_data=Z, x_coverage=5, y_coverage=10)
            Notebook.AddPage(plot2, "3d Plot")

            plot3 = plot(Notebook)
            x1 = npy.arange(-10, 10, 0.5)
            x2 = npy.arange(0, 20, 0.5)
            data = npy.column_stack((x1, x1 ** 2, x2, x2 ** 3))
            plot3.plot_2d_double(data, 0, 1, 2, 3)
            Notebook.AddPage(plot3, "double 2dplot")

            ##        panel.Layout()
            self.Show(True)
Пример #6
0
def plot_charge_den():
    """Test function; Was not used"""
    from mpl_toolkits.mplot3d import axes3d
    import matplotlib.pyplot as plt
    from matplotlib import cm

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    # print X
    # print Y
    # print Z

    ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
    # cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
    # cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    # cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

    ax.set_xlabel('X')
    ax.set_xlim(-40, 40)
    ax.set_ylabel('Y')
    ax.set_ylim(-40, 40)
    ax.set_zlabel('Z')
    ax.set_zlim(-100, 100)

    plt.show()

    return
Пример #7
0
def noisy_test_data(num):
    X, Y, Z = axes3d.get_test_data(0.05)

    x = np.random.randint(0, Z.shape[0], num)
    y = np.random.randint(0, Z.shape[1], num)
    for i, j in zip(x, y):
        Z[i, j] = np.random.random_sample() * 8
    return Z
Пример #8
0
def test_mixedsamplesraises():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    with pytest.raises(ValueError):
        ax.plot_wireframe(X, Y, Z, rstride=10, ccount=50)
    with pytest.raises(ValueError):
        ax.plot_surface(X, Y, Z, cstride=50, rcount=10)
Пример #9
0
def test_wireframe3dzerostrideraises():
    if sys.version_info[:2] < (2, 7):
        raise nose.SkipTest("assert_raises as context manager " "not supported with Python < 2.7")
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="3d")
    X, Y, Z = axes3d.get_test_data(0.05)
    with assert_raises(ValueError):
        ax.plot_wireframe(X, Y, Z, rstride=0, cstride=0)
Пример #10
0
def contour_demo2(**kwargs):
    import mpl_toolkits.mplot3d.axes3d as axes3d
    from ifigure.interactive import contourf, threed, figure, hold
    X, Y, Z = axes3d.get_test_data(0.05) 
    v = figure(gl = True)
    threed('on')
    hold('on')
    contourf(X, Y, Z)    
    contourf(X, Y, Z, zdir = 'x', offset = -40)
Пример #11
0
def test_contour3d():
    fig = plt.figure()
    ax = fig.gca(projection="3d")
    X, Y, Z = axes3d.get_test_data(0.05)
    cset = ax.contour(X, Y, Z, zdir="z", offset=-100, cmap=cm.coolwarm)
    cset = ax.contour(X, Y, Z, zdir="x", offset=-40, cmap=cm.coolwarm)
    cset = ax.contour(X, Y, Z, zdir="y", offset=40, cmap=cm.coolwarm)
    ax.set_xlim(-40, 40)
    ax.set_ylim(-40, 40)
    ax.set_zlim(-100, 100)
Пример #12
0
def draw_wireframe():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    x, y, z = axes3d.get_test_data(0.05)
    # def z_func(x,y):
    #     return x+y
    z = x**2+y**4
    ax.plot_wireframe(x, y, z, rstride=10, cstride=10)

    plt.show()
Пример #13
0
def solve2():
    plt.ion()
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.1)
    print X.shape
    print Z.shape
    ax.scatter(X, Y, Z)

    plt.show()
Пример #14
0
def test_contourf3d():
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
    cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)
    ax.set_xlim(-40, 40)
    ax.set_ylim(-40, 40)
    ax.set_zlim(-100, 100)
Пример #15
0
def plot():
    #numpy.set_printoptions(threshold='nan')
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    print X
    ax.set_xlabel('TIME (DAYS)')
    ax.set_ylabel('Optimal Minimized Risk')
    ax.set_zlabel('Price (USD$)')

    ax.plot_surface(X, Y, Z,cmap=plt.cm.jet, rstride=10, cstride=10)
    plt.show()
Пример #16
0
def wire():
    from mpl_toolkits.mplot3d import axes3d
    import matplotlib.pyplot as plt
    import numpy as np

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    x, y, z = axes3d.get_test_data(0.05)
    x = np.linspace(1,10,100)
    y = np.linspace(4,10,100)
    z = np.linspace(8,10,100)
    ax.plot_wireframe(x, y, z, rstride=10, cstride=10)

    plt.show()
def grafica():
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    ax.plot_surface(X, Y, Z, rstride=3, cstride=8, alpha=0.3)
    # cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
    # cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    # cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

    ax.set_xlabel('X')
    ax.set_xlim(-40, 40)
    ax.set_ylabel('Y')
    ax.set_ylim(-40, 40)
    ax.set_zlabel('Z')
    ax.set_zlim(-100, 100)

    plt.show()
def show3D():
    '''Generation of 3D plots'''
    
    # imports specific to the plots in this example
    from matplotlib import cm   # colormaps
    
    # This module is required for 3D plots!
    from mpl_toolkits.mplot3d import Axes3D
    
    # Twice as wide as it is tall.
    fig = plt.figure(figsize=plt.figaspect(0.5))
    setFonts(16)
    
    #---- First subplot
    # Generate the data
    X = np.arange(-5, 5, 0.1)
    Y = np.arange(-5, 5, 0.1)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)
    
    # Note the definition of "projection", required for 3D  plots
    #plt.style.use('ggplot')

    ax = fig.add_subplot(1, 2, 1, projection='3d')
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.GnBu,
            linewidth=0, antialiased=False)
    #surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis_r,
            #linewidth=0, antialiased=False)
    ax.set_zlim3d(-1.01, 1.01)
    
    fig.colorbar(surf, shrink=0.5, aspect=10)
    
    #---- Second subplot
    # Get some 3d test-data
    from mpl_toolkits.mplot3d.axes3d import get_test_data
    
    ax = fig.add_subplot(1, 2, 2, projection='3d')
    X, Y, Z = get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

    showData('3dGraph.png')
Пример #19
0
def generate_test_data():
    """
    Borrowed from http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html
    """
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    X, Y, Z = axes3d.get_test_data( 0.1 )
    Z = np.abs( Z )

    ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
    cset = ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm)
    cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

    ax.set_xlabel('X')
    ax.set_xlim(-40, 40)
    ax.set_ylabel('Y')
    ax.set_ylim(-40, 40)
    ax.set_zlabel('Z')
    ax.set_zlim(-1, 100)

    plt.show()

    return Z
Пример #20
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import style

style.use('fivethirtyeight')

fig = plt.figure()
ax1 = fig.add_subplot(
    111, projection='3d')  # notify that the graphs is 3 dimensions

x, y, z = axes3d.get_test_data()  # gives test data

print(axes3d.__file__)
ax1.plot_wireframe(x, y, z, rstride=5,
                   cstride=5)  #rstride and cstride creates distance

ax1.set_xlabel('X-Axis')
ax1.set_ylabel('Y-Axis')
ax1.set_zlabel('Z-Axis')
ax1.grid(True)

plt.show()
Пример #21
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np

style.use('fivethirtyeight')

fig1 = plt.figure(1)
fig2 = plt.figure(2)
ax1 = fig1.add_subplot(111, projection='3d')

ax2 = fig2.add_subplot(111, projection='3d')
X, Y, Z = axes3d.get_test_data()  ## this creates n-dim lists for X,Y,Z
print(type(X))

A = np.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]])
B = np.array([[4, 2, 6, 5], [4, 2, 6, 5], [4, 2, 6, 5], [4, 2, 6, 5]])
C = np.array([[3, 6, 8, 7], [3, 6, 8, 7], [3, 6, 8, 7], [3, 6, 8, 7]])

x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
y = np.array([[5, 6, 7, 8, 2, 5, 6, 3, 7, 2]])
z = np.array([[1, 2, 6, 3, 2, 7, 3, 3, 7, 2]])
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = [4, 4, 1, 7, 3, 8, 1, 6, 3, 7]
c = [7, 8, 4, 9, 9, 4, 8, 6, 3, 9]

##ax1.plot(a, b, c)  ## This is a line graph in 3d plain, we see 1 line
ax1.scatter(a, b, c, c='g', marker='o')
ax1.scatter(x[0], y[0], z[0], c='r',
            marker='o')  ## The previous data remains, the new data is added
## to the graph
chart.set_xlabel('xlabel')
chart.set_ylabel('ylabel')
chart.set_zlabel('zlabel')

plt.show()

#wireframes
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
chart = fig.add_subplot(1, 1, 1, projection='3d')

x, y, z = axes3d.get_test_data(0.05)  #0.05 is the delta for fast computation
chart.plot_wireframe(x, y, z, rstride=10, cstride=10)
#rstride=cstride=no of lines(more detailed)

chart.set_xlabel('xlabel')
chart.set_ylabel('ylabel')
chart.set_zlabel('zlabel')

plt.show()

###################pandas##################
#####Series(is the 1-dimensional data structures)
import pandas as pd
s = pd.Series([20, "sujith", 78, 'Hello'])  #with list
s
s[0]
Пример #23
0
def test_wireframe3dzerocstride():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rcount=13, ccount=0)
Пример #24
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)
ax.clabel(cset, fontsize=9, inline=1)

plt.show()
Пример #25
0
def test_wireframe3dzerorstride():
    fig = plt.figure()
    ax = fig.add_subplot(projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=0, cstride=10)
Пример #26
0
Shubham Patel
Github: github.com/shubham-00
LinkedIn: https://www.linkedin.com/in/srpatel980/
Contact for more.
'''

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()  # Creating an empty figure
ax = fig.add_subplot(111, projection="3d")  # Added an empty 3d plot
# 111 means 1*1 grid and 1st subplot
# abc means a*b grid and cth subplot

x, y, z = axes3d.get_test_data(delta=0.1)
ax.plot_wireframe(x, y, z, rstride=3, cstride=3)
# rstride, cstride => how often we draw a line (row, colunm)
# delta => how often we compute a line

ax.set_title("3D Plane")
ax.set_xlabel("X axis")
ax.set_ylabel("Y axis")
ax.set_zlabel("Z axis")

#print(x, y, z)

plt.show()
'''
Shubham Patel
Github: github.com/shubham-00
Пример #27
0
def taylor_expansion_3d(exp):
    x, y, z = sp.symbols('x y z')
    # calculating constants
    grad_x = exp.diff(x)
    grad_y = exp.diff(y)
    print(grad_x, grad_y)

    grad_xx = grad_x.diff(x)
    grad_xy = grad_x.diff(y)
    grad_yy = grad_y.diff(y)
    grad_yx = grad_y.diff(x)

    vec1_list = []
    taylor_values = []
    vec2_list = []
    xlist = []
    ylist = []
    for a in np.arange(0, 3, 1):
        for b in np.arange(0, 3, 1):

            # first term ==  f(a,b)
            first_term = exp.subs(x, a)
            first_term = first_term.subs(y, b)
            # print(first_term)

            # second term == f'(a,b)*(x-a) + f'(a,b)*(y-b)
            grad_1x = grad_x.subs(x, a)
            grad_1y = grad_y.subs(y, b)
            second_term = (grad_1x * (x - a) + grad_1y *
                           (y - b)) / factorial(1)
            # print(second_term)

            # third term == (f''(a,b)*(x-a)**2 + f''(a,b)*(x-a)*(y-b) + f''(a,b)*(y-b)**2)/2
            grad_2xx = grad_xx.subs(x, a)
            grad_2yy = grad_yy.subs(y, b)
            grad_2xy = grad_xy.subs([x, y], [a, b])
            grad_2yx = grad_yx.subs([x, y], [a, b])
            third_term = (grad_2xx * (x - a)**2 + (grad_2xy + grad_2yx) *
                          (x - a) * (y - b) + grad_2yy *
                          (y - b)**2) / factorial(2)
            # print(third_term)

            vec1_list.append([a, b])

    for xval in np.arange(0, 5, 0.5):
        for yval in np.arange(0, 5, 0.5):

            taylor_exp = first_term + second_term + third_term
            taylor_exp = taylor_exp.subs(x, xval)
            taylor_exp = taylor_exp.subs(y, yval)
            taylor_exp = round(taylor_exp, 2)
            taylor_values.append(taylor_exp)
            #vec2_list.append([xval, yval])
            xlist.append(xval)
            ylist.append(yval)

    print(xlist)
    print(ylist)
    print(taylor_values)

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    x, y, z = axes3d.get_test_data(0.05)
    print(x)
    print(y)
    print(z)
    ax.plot_wireframe(xlist, ylist, taylor_values, rstride=5, cstride=5)
    plt.show()
Пример #28
0
# PyCharm
# Python大数据
# test3X
# 御承扬
# 2019/12/9


from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

if __name__ == '__main__':
    fig = plt.figure(figsize=(8, 6))
    ax = fig.gca(projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)  ## 生成二维测试数据
    ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
    cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
    cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    cset = ax.contour(X, Y, Z, zdir='y', offset=-40, cmap=cm.coolwarm)
    ax.set_xlabel('X')
    ax.set_xlim(-40, 40)
    ax.set_ylabel('y')
    ax.set_ylim(-40, 40)
    ax.set_zlabel('z')
    ax.set_zlim(-100, 100)
    plt.show()

Пример #29
0
y = [4, 8, 7, 2, 6, 9, 8, 1, 2, 4]
z = [9, 4, 1, 2, 7, 5, 3, 4, 5, 8]

#ax1.plot_wireframe(x, y, z)

x2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]
y2 = [-4, -8, -7, -2, -6, -9, -8, -1, -2, -4]
z2 = [9, 4, 1, 2, 7, 5, 3, 4, 5, -8]

#ax1.scatter(x, y, z, c='b', marker='o')
#ax1.scatter(x2, y2, z2, c='r', marker='o')

x3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y3 = [4, 8, 7, 2, 6, 9, 8, 1, 2, 4]
z3 = np.zeros(10)
# if use numbers instead of 'zeros', the bars will be 'floating in the air'

dx = np.ones(10)
dy = np.ones(10)
dz = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

#ax1.bar3d(x3, y3, z3, dx, dy, dz)

x4, y4, z4 = axes3d.get_test_data()
ax1.plot_wireframe(x4, y4, z4, rstride=5, cstride=5)

ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')

plt.show()
Пример #30
0
import numpy as np
from scipy.interpolate import griddata
import scipy.ndimage as ndimage
from scipy.ndimage import gaussian_filter
from scipy.misc import imsave
from matplotlib import cm
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from stl import mesh, Mode
import matplotlib.tri as mtri
from mpl_toolkits.mplot3d.axes3d import get_test_data

# Generating the surface
x, y, z = get_test_data(delta=0.1)
# Scale the surface for this example
z *= 0.05
# Remember that Gazebo uses ENU (east-north-up) convention, so underwater
# the Z coordinate will be negative
z -= 3
# Note: Gazebo will import your mesh in meters.

# Point clouds usually don't come in nice grids, so let's make it a (N, 3)
# matrix just to show how it can be done. If you have outliers or noise, you should
# treat those values now.
xyz = np.zeros(shape=(x.size, 3))
xyz[:, 0] = x.flatten()
xyz[:, 1] = y.flatten()
xyz[:, 2] = z.flatten()

# Generate a grid for the X and Y coordinates, change the number of points
# to your needs. Large grids can generate files that are too big for Gazebo, so
def _generate_hills(size):
    "Generates noisy hills test data"
    _, _, data = axes3d.get_test_data(6.0 / size)
    return -0.1 * data  # to make in about the same height as the circles
Пример #32
0
    def __init__(self, parent, controller):

        tk.Frame.__init__(self, parent)

        label = ttk.Label(self, text="Wireframe")
        label.pack(pady=10, padx=10)

        ttk.Style().configure("RB.TButton",
                              foreground='black',
                              background='orange')

        ButtonHome = ttk.Button(
            self,
            text="Back",
            style="RB.TButton",
            command=lambda: controller.show_frame(WireFrameInfo)).place(x=0,
                                                                        y=0)

        #Figure creation and assignment
        self.fig = plt.figure()
        ax = self.fig.add_subplot(111, projection='3d', axisbg='orange')

        #sets background color
        rect = self.fig.patch
        rect.set_facecolor('orange')

        #delta how often we're going to compute the line
        x, y, z = axes3d.get_test_data(0.05)

        #rstride is how often we draw a line
        ax.plot_surface(x,
                        y,
                        z,
                        cmap=cm.autumn,
                        rstride=2,
                        cstride=2,
                        alpha=0.3)
        cset = ax.contour(x, y, z, zdir='z', offset=-100, cmap=cm.autumn)
        cset = ax.contour(z, y, z, zdir='x', offset=-40, cmap=cm.autumn)
        cset = ax.contour(z, y, z, zdir='y', offset=40, cmap=cm.autumn)

        ax.spines['bottom'].set_color('orange')
        ax.spines['right'].set_color('orange')
        ax.spines['left'].set_color('orange')
        ax.spines['top'].set_color('orange')

        ax.set_xlim(-40, 40)
        ax.set_ylim(-40, 40)
        ax.set_zlim(-100, 100)

        style.use("ggplot")

        canvas = FigureCanvasTkAgg(self.fig, self)
        #Canvas border color
        canvas.get_tk_widget().configure(background='orange',
                                         highlightcolor='orange',
                                         highlightbackground='orange')
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        toolbar = NavigationToolbar2TkAgg(canvas, self)
        toolbar.update()

        self.configure(background='orange')
Пример #33
0
ax.grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)
ax.set_ylabel('Grafica 1')

ax = fig.add_subplot(2, 2, 2)
ax.plot(Xa, Vxb, color="red", linewidth=1.0, linestyle="-")
ax.title.set_text('Eje X2 vs V')
ax.grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)
ax.set_ylabel('Grafica 2')
"""
ax = fig.add_subplot(2, 2, 3)
ax.plot(Xa, Vxy, color="green", linewidth=1.0, linestyle="-")
ax.title.set_text('Eje X,Y vs V')
ax.grid(color='b', alpha=0.5, linestyle='dashed', linewidth=0.5)
ax.set_ylabel('Grafica 3')
"""
from mpl_toolkits.mplot3d.axes3d import get_test_data
ax = fig.add_subplot(2, 2, 3, projection='3d')
X, Y, Vtt = get_test_data(0.05)
ax.plot_wireframe(X, Y, Vtt, rstride=10, cstride=10)

#------------------------------------------------------------------------------
# GRAFICAS 3D
#------------------------------------------------------------------------------
ax = fig.add_subplot(2, 2, 4, projection='3d')
X, Y = np.meshgrid(Xa, Ya)
surf = ax.plot_surface(X, Y, Vtt, cmap=cm.get_cmap("jet"), antialiased=False)
ax.set_zlim(300, 1800)
fig.colorbar(surf)
#------------------------------------------------------------------------------
plt.pause(25)
pl.savefig('tierras.pdf')
Пример #34
0
def get_data(p):
    x, y, z = axes3d.get_test_data(p)
    z = f * z
    return x, y, z
Пример #35
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Grab some test data.
X, Y, Z = axes3d.get_test_data(1000)

# Plot a basic wireframe.
#ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

plt.show()
Пример #36
0
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from mpl_toolkits.mplot3d.axes3d import get_test_data
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure(figsize=plt.figaspect(0.5))

x, y, z = get_test_data(0.05)
zlv = np.linspace(-85, 85, 35)

# 第一个子图
ax1 = fig.add_subplot(1, 2, 1)
ct = ax1.contourf(x, y, z, levels=zlv, cmap=cm.coolwarm)
fig.colorbar(ct, shrink=0.7, aspect=15, ticks=zlv[1::8])

# 第二个子图
ax2 = fig.add_subplot(1, 2, 2, projection='3d')
sf = ax2.plot_surface(x,
                      y,
                      z,
                      rstride=1,
                      cstride=1,
                      vmin=zlv[0],
                      vmax=zlv[-1],
                      cmap=cm.bwr)
fig.colorbar(sf, shrink=0.7, aspect=15, orientation='horizontal')

plt.show()
Пример #37
0
from mpl_toolkits.mplot3d.axes3d import get_test_data

plt.style.use('seaborn')

# example1
'''
x = np.linspace(-10, 10, 200)
y = np.linspace(-10, 10, 200)

X, Y = np.meshgrid(x, y)
Z = X**2 + Y**2
levels = np.geomspace(Z.min(), Z.max(), 100)
'''

# example2
X, Y, Z = get_test_data(0.05)
levels = np.linspace(Z.min(), Z.max(), 100)

fig = plt.figure(figsize=(14, 7))
ax1 = fig.add_subplot(121, projection='3d')
ax2 = fig.add_subplot(122)

# wireframe
ax1.plot_wireframe(X, Y, Z)

# contour/contourf
#ax2.contour(X, Y, Z, cmap='bwr', levels=levels)
contourf = ax2.contourf(X, Y, Z, cmap='bwr', levels=levels)
cbar = fig.colorbar(contourf, pad=0., fraction=0.15)

contourf_zero = ax2.contour(X,
# - http://www.astropy.org/astropy-tutorials/FITS-tables.html
# - http://www.astropy.org/astropy-tutorials/FITS-images.html
# - http://www.astropy.org/astropy-tutorials/FITS-header.html

import os.path

from astropy.io import fits
import numpy as np

from mpl_toolkits.mplot3d import axes3d

OUTPUT_PATH = "out.fits"

# CREATE DATA #########################

X1, Y1, Z1 = axes3d.get_test_data(0.05)
X2, Y2, Z2 = axes3d.get_test_data(0.05)
X3, Y3, Z3 = axes3d.get_test_data(0.05)

Z1 *= 1.
Z2 *= -1.
Z3 *= 2.

img = np.stack([Z1, Z2, Z3], 0)

print("Image shape:", img.shape)

# CREATE THE FITS STRUCTURE ###########

hdu = fits.PrimaryHDU(img)
Пример #39
0
def test_wireframe3dzerostrideraises():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    with pytest.raises(ValueError):
        ax.plot_wireframe(X, Y, Z, rstride=0, cstride=0)
Пример #40
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np

plt.style.use('dark_background')

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Grab some test data.
X = np.array([[0], [100], [0], [0]])
Y = np.array([[0], [0], [0], [0]])
Z = np.array([[0], [100], [0], [0]])

print(axes3d.get_test_data(0.05))
# Plot a basic wireframe.
ax.plot_wireframe(
    X,
    Y,
    Z,
)

plt.show()
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np

style.use('ggplot')

fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')

x, y, z = axes3d.get_test_data()
ax1.plot_wireframe(x, y, z, rstride=5, cstride=5)

ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')

plt.show()
Пример #42
0
from mpl_toolkits.mplot3d.axes3d import Axes3D
import matplotlib.pyplot as plt


# imports specific to the plots in this example
import numpy as np
from matplotlib import cm
from mpl_toolkits.mplot3d.axes3d import get_test_data

# Twice as wide as it is tall.
fig = plt.figure(figsize=plt.figaspect(0.5))

#---- First subplot
ax = fig.add_subplot(1, 2, 1, projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
        linewidth=0, antialiased=False)
ax.set_zlim3d(-1.01, 1.01)

fig.colorbar(surf, shrink=0.5, aspect=10)

#---- Second subplot
ax = fig.add_subplot(1, 2, 2, projection='3d')
X, Y, Z = get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

plt.show()
Пример #43
0
from mpl_toolkits.mplot3d import axes3d
from pylab import *
import numpy as np
p=[]
q=[]
x,y,z= axes3d.get_test_data(0.05)
for i in range(10):
	p.append(i^1)
	q.append(i^2)
l=range(10)
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(1, 1, 1,projection='3d')
ax.set_xlabel('base value from 0 to 9 Label')
ax.set_ylabel('i^1 Label')
ax.set_zlabel('i^2 Label')
ax.grid(True)
#ax.grid(color='r', alpha=0.2, linestyle='dashed', linewidth=0.5)
p = ax.plot_surface(l,p,q,rstride=4, cstride=4) # might be plot_surface
plt.show()
Пример #44
0
def test_wireframe3dzerostrideraises():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    with pytest.raises(ValueError):
        ax.plot_wireframe(X, Y, Z, rstride=0, cstride=0)
Пример #45
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d

fig = plt.figure(figsize=(5, 6))
ax = plt.subplot(111, projection="3d")

X, Y, Z = axes3d.get_test_data()  #delta = 0.05

ax.plot_surface(X, Y, Z, rstride=10, cstride=10, cmap=plt.get_cmap("winter"))
ax.view_init(20, 120)
plt.show()
Пример #46
0
def test2d(paramlist, show, val):
    #print(val)
    #print(paramlist)
    fimtgd = FIMTGD(gamma=paramlist[0],
                    n_min=paramlist[1],
                    alpha=[2],
                    threshold=paramlist[3],
                    learn=paramlist[4])
    fimtls = FIMTLS(gamma=paramlist[0],
                    n_min=paramlist[1],
                    alpha=[2],
                    threshold=paramlist[3],
                    learn=paramlist[4])
    gfimtls = gFIMTLS(gamma=paramlist[0],
                      n_min=paramlist[1],
                      alpha=[2],
                      threshold=paramlist[3],
                      learn=paramlist[5])
    cumLossgd = [0]
    cumLossls = [0]
    cumLossgls = [0]
    if True:
        start = 0.0
        end = 1.0
        X = list()
        Y = list()
        x, y, z = axes3d.get_test_data(0.1)
        num_d = len(x)**2
        for i in range(len(x)):
            for j in range(len(y)):
                input = [x[i, j], y[i, j]]
                target = z[i, j]

                X.append(input)
                Y.append(target)
        data = [X, Y]
        data = np.array(data)
        data = data.transpose()
        np.random.shuffle(data)
        data = data.transpose()

        for i in range(num_d):

            input = data[0][i]
            target = data[1][i] + (np.random.uniform() - 0.5) * 0.2
            o_target = data[1][i]

            if num_d / 2 < i:
                target += 1.0
                o_target += 1.0

            cumLossgd.append(cumLossgd[-1] + np.fabs(
                o_target - fimtgd.eval_and_learn(np.array(input), target)))
            cumLossls.append(cumLossls[-1] + np.fabs(
                o_target - fimtls.eval_and_learn(np.array(input), target)))
            cumLossgls.append(cumLossgls[-1] + np.fabs(
                o_target - gfimtls.eval_and_learn(np.array(input), target)))
            #plt.scatter(x=x,y=y)
            #plt.show()
            if show:
                f = plt.figure()
                plt.plot(cumLossgd[1:], label="Gradient Descent Loss")
                f.hold(True)
                plt.plot(cumLossls[1:], label="Filter Loss")
                #avglossgd=np.array([cumLossgd[-1]/len(cumLossgd)]*len(cumLossgd))
                #plt.plot(avglossgd,label="Average GD Loss")
                #plt.plot([cumLossls[-1]/len(cumLossls)]*len(cumLossls), label="Average Filter Loss")
                plt.title("CumLoss Ratio:" + str(
                    min(cumLossgd[-1], cumLossls[-1]) /
                    max(cumLossgd[-1], cumLossls[-1])))
                plt.legend()
                figname="g"+str(paramlist[0])+"_nmin"+str(paramlist[1])+"_al"+str(paramlist[2])+"_thr"+str(paramlist[3])\
                        + "_lr"+str(paramlist[4])+".png"
                plt.savefig(figname)
                #plt.show()
                f.clear()
            #print(i)
            #print(fimtgd.count_leaves())
            #print(fimtgd.count_nodes())
        return [cumLossgd, cumLossls, cumLossgls, val, paramlist]
Пример #47
0
# -*- coding: utf-8 -*-

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure(figsize=(16, 12))
ax1 = fig.add_subplot(111, projection='3d')
X, Y, Z = axes3d.get_test_data(0.1)  #测试数据
print X, "\n#" * 2, Y, "\n#" * 2, Z
#cset = ax1.contour(X, Y, Z, cmap=cm.coolwarm)  #color map选用的是coolwarm
cset = ax1.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)
ax1.set_title("Contour plot", color='b', weight='bold', size=25)
plt.show()

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import axes3d

fig = plt.figure(figsize=(16, 12))
ax2 = fig.gca(projection="3d")  # get current axis
X, Y, Z = axes3d.get_test_data(0.001)  #测试数据

ax2.plot_surface(X, Y, Z, rstride=4, cstride=4, alpha=0.5, cmap=cm.coolwarm)
cset = ax2.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax2.contour(X, Y, Z, zdir="x", offset=-40,
                   cmap=cm.coolwarm)  #沿x轴方向投影(将x轴作为新坐标系的z轴,在新坐标系的xy平面作图。)
cset = ax2.contour(X, Y, Z, zdir="y", offset=-40, cmap=cm.coolwarm)
Пример #48
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X, Y, Z = range(6), [5, 6, 3, 1, 5, 2], [8, 7, 6, 8, 7, 5]
X2, Y2, Z2 = [2, 3, 4, 5, 6, 7], [5, 6, 3, 1, 5, 2], range(6)
X3, Y3, Z3 = [5, 6, 3, 1, 5, 2], range(6), [2, 3, 4, 5, 6, 7]
X, Y, Z = axes3d.get_test_data(0.05)  #every axe gets a matrix
#print len(X),X[0]

#bar charts
#xpos=range(1,11)	#origin of points
#ypos=[2,3,4,5,1,6,2,1,7,2]
#zpos=[0]*10
#zpos[4]=4
#dx=[1]*10	#distance to move on directions
#dy=[1]*10
#dz=range(1,11)

#ax.plot_wireframe(X,Y,Z)	#one line
#ax.scatter(X,Y,Z, c='green', marker='o')	#only dots
#ax.scatter(X2,Y2,Z2, c='red', marker='v')	#only dots
#ax.scatter(X3,Y3,Z3, c='blue', marker='^')	#only dots
#ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#00ccaa')	#3d bars
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=2)  #planos 3d

ax.set_xlabel('Eje X')
ax.set_ylabel('Eje Y')
ax.set_zlabel('Eje Z')
Пример #49
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()

ax1 = fig.add_subplot(111, projection='3d')
'''
x = [1,2,3,4,5,6,7,8,9,10]
y = [5,6,7,8,2,5,6,3,7,2]
z = [1,2,6,3,2,7,3,3,7,2]

ax1.plot_wireframe(x,y,z)
'''
'''
x2 = [-1,-2,-3,-4,-5,-6,-7,-8,-9,-10]
y2 = [-5,-6,-7,-8,-2,-5,-6,-3,-7,-2]
z2 = [1,2,6,3,2,7,3,3,7,2]

ax1.scatter(x,y,z, c='g', marker='o')
ax1.scatter(x2,y2,z2, c='r', marker='^')
'''
x3,y3,z3 = axes3d.get_test_data()
ax1.plot_wireframe(x3,y3,z3,rstride=5,cstride=5)


ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')

plt.show()
Пример #50
0
                       Y,
                       Z,
                       rstride=1,
                       cstride=1,
                       cmap=cm.rainbow,
                       linewidth=0,
                       antialiased=False)

ax.set_zlim(-1.01, 1.01)

fig.colorbar(surf, shrink=0.5, aspect=10)

#第二個子圖
ax = fig.add_subplot(1, 3, 2, projection='3d')

X, Y, Z = get_test_data(0.1)

# ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)

surf = ax.plot_surface(X,
                       Y,
                       Z,
                       rstride=1,
                       cstride=1,
                       cmap=cm.rainbow,
                       linewidth=0,
                       antialiased=False)

fig.colorbar(surf, shrink=0.5, aspect=10)

# 3
Пример #51
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
fig = plt.figure()
ax = axes3d.Axes3D(fig)
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)
for angle in range(0, 360):
    ax.view_init(30, angle)
    plt.draw()
Пример #52
0
def test_has_matplotlib():
    import pathlib
    from io import BytesIO

    import matplotlib
    matplotlib.use('Agg')

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.tri as mtri
    from cycler import cycler
    from matplotlib import cm
    from mpl_toolkits.mplot3d.axes3d import get_test_data

    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)

    fig = plt.figure(figsize=(19.2, 14.4))
    ax = fig.add_subplot(3, 3, 1, projection='3d')
    ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)

    ax.set_title('matplotlib')

    ax2 = fig.add_subplot(3, 3, 2, projection='3d')
    X, Y, Z = get_test_data(0.05)
    ax2.plot_wireframe(X, Y, Z, rstride=5, cstride=5, linestyles='dashdot')

    ax2.set_title('3d')

    u = np.linspace(0, 2.0 * np.pi, endpoint=True, num=50)
    v = np.linspace(-0.5, 0.5, endpoint=True, num=10)
    u, v = np.meshgrid(u, v)
    u, v = u.flatten(), v.flatten()

    x = (1 + 0.5 * v * np.cos(u / 2.0)) * np.cos(u)
    y = (1 + 0.5 * v * np.cos(u / 2.0)) * np.sin(u)
    z = 0.5 * v * np.sin(u / 2.0)

    tri = mtri.Triangulation(u, v)

    ax3 = fig.add_subplot(3, 3, 3, projection='3d')
    ax3.plot_trisurf(x, y, z, triangles=tri.triangles, cmap=cm.jet)

    ax3.set_title('plot')

    radii = np.linspace(0.125, 1.0, 8)
    angles = np.linspace(0, 2*np.pi, 36, endpoint=False)

    angles = np.repeat(angles[..., np.newaxis], 8, axis=1)

    x = np.append(0, (radii*np.cos(angles)).flatten())
    y = np.append(0, (radii*np.sin(angles)).flatten())

    z = np.sin(-x*y)

    ax4 = fig.add_subplot(3, 3, 4, projection='3d')
    ax4.plot_trisurf(x, y, z, linewidth=0.2, cmap=cm.Spectral)

    ax4.set_title('test')

    X, Y, Z = get_test_data(0.05)
    ax5 = fig.add_subplot(3, 3, 5, projection='3d')
    ax5.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)

    ax5.set_title('for')

    ax6 = fig.add_subplot(3, 3, 6, projection='3d')

    ax6.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
    ax6.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
    ax6.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
    ax6.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

    ax6.set_xlim(-40, 40)
    ax6.set_ylim(-40, 40)
    ax6.set_zlim(-100, 100)

    ax6.set_title('docker')

    theta = np.linspace(0.0, 2 * np.pi, 20, endpoint=False)
    radii = 10 * np.random.rand(20)
    width = np.pi / 4 * np.random.rand(20)

    ax7 = fig.add_subplot(3, 3, 7, projection='polar')
    bars = ax7.bar(theta, radii, width=width, bottom=0.0)

    for r, bar in zip(radii, bars):
        bar.set_facecolor(cm.viridis(r / 10.))
        bar.set_alpha(0.5)

    ax7.set_title('also this')

    x = np.linspace(0, 2 * np.pi)
    offsets = np.linspace(0, 2*np.pi, 4, endpoint=False)

    yy = np.transpose([np.sin(x + phi) for phi in offsets])

    ax8 = fig.add_subplot(3, 2, 6)
    ax8.set_prop_cycle(cycler('color', ['r', 'g', 'b', 'y']) +
                    cycler('linestyle', ['-', '--', ':', '-.']))

    ax8.plot(yy)

    ax8.set_title('and one of these too')

    # check it writes to buffer properly first
    out_buffer = BytesIO()
    plt.savefig(out_buffer, dpi=160, format='png', bbox_inches='tight')
    out_buffer.seek(0)

    assert out_buffer.read(4) == b'\x89PNG'

    # write to file for good measure
    with open('_test_plot_image.png', 'wb') as op:
        op.write(b'\x89PNG' + out_buffer.read())

    assert pathlib.Path('_test_plot_image.png').exists()
Пример #53
0
def test_wireframe3dzerocstride():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rcount=13, ccount=0)
Пример #54
0
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig=plt.figure()
ax=fig.add_subplot(111, projection='3d')
X, Y, Z = range(6), [5,6,3,1,5,2], [8,7,6,8,7,5]
X2, Y2, Z2 = [2,3,4,5,6,7], [5,6,3,1,5,2], range(6)
X3, Y3, Z3 = [5,6,3,1,5,2], range(6), [2,3,4,5,6,7]
X, Y, Z = axes3d.get_test_data(0.05)	#every axe gets a matrix
#print len(X),X[0]

#bar charts
#xpos=range(1,11)	#origin of points
#ypos=[2,3,4,5,1,6,2,1,7,2]
#zpos=[0]*10
#zpos[4]=4
#dx=[1]*10	#distance to move on directions
#dy=[1]*10
#dz=range(1,11)

#ax.plot_wireframe(X,Y,Z)	#one line
#ax.scatter(X,Y,Z, c='green', marker='o')	#only dots
#ax.scatter(X2,Y2,Z2, c='red', marker='v')	#only dots
#ax.scatter(X3,Y3,Z3, c='blue', marker='^')	#only dots
#ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#00ccaa')	#3d bars
ax.plot_wireframe(X,Y,Z, rstride=5, cstride=2)	#planos 3d

ax.set_xlabel('Eje X')
ax.set_ylabel('Eje Y')
ax.set_zlabel('Eje Z')
Пример #55
0
"""
.. versionadded:: 1.1.0
   This demo depends on new features added to contourf3d.
"""

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')
from pprint import pprint
pprint(axes3d.get_test_data(0.05))
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

ax.set_xlabel('X')
ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z')
ax.set_zlim(-100, 100)

plt.show()

ax2 = fig.add_subplot(122)
cs = ax2.contour(X4, Y4, Z4, 15,
                 cmap='jet')  #contour将三维图像在二维空间上表示,15代表等高线的密集程度,数值越大线越多

ax2.clabel(cs, inline=True, fontsize=10, fmt='%1.1f')  #clabel函数在每条线上显示数据值的大小
plt.title('二维显示', fontproperties=font)
'''绘制三维曲线'''

from mpl_toolkits.mplot3d.axes3d import get_test_data

fig5 = plt.figure(figsize=(8, 6))
ax5 = fig5.gca(projection='3d')

#生成三维测试数据
X5, Y5, Z5 = get_test_data(0.05)

ax5.plot_surface(X5, Y5, Z5, rstride=8, cstride=8, alpha=0.3)
cset = ax5.contour(X5, Y5, Z5, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax5.contour(X5, Y5, Z5, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax5.contour(X5, Y5, Z5, zdir='y', offset=40, cmap=cm.coolwarm)

ax5.set_xlabel('X')
ax5.set_ylabel('Y')
ax5.set_zlabel('Z')

ax5.set_xlim(-40, 40)
ax5.set_ylim(-40, 40)
ax5.set_zlim(-100, 100)

plt.show()
Пример #57
0
def test_wireframe3d():
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    X, Y, Z = axes3d.get_test_data(0.05)
    ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)
Пример #58
0
                                              monotone=True)
fd_monotone.plot(label="PCHIP")

fd_monotone.scatter(c='C1')
plt.legend()

###############################################################################
# All the interpolators will work regardless of the dimension of the image, but
# depending on the domain dimension some methods will not be available.
#
# For the next examples it is constructed a surface, :math:`x_i: \mathbb{R}^2
# \longmapsto \mathbb{R}`. By default, as in unidimensional samples, it is used
# linear interpolation.
#

X, Y, Z = axes3d.get_test_data(1.2)
data_matrix = [Z.T]
sample_points = [X[0, :], Y[:, 0]]

fd = skfda.FDataGrid(data_matrix, sample_points)

fig, ax = fd.plot()
fd.scatter(ax=ax)

###############################################################################
# In the following figure it is shown the result of the cubic interpolation
# applied to the surface.
#
# The degree of the interpolator polynomial does not have to coincide in both
# directions, for example, cubic interpolation in the first
# component and quadratic in the second one could be defined  using a tuple with
Пример #59
0
import math
import matplotlib.pyplot as plt
from matplotlib.mlab      import griddata
from mpl_toolkits.mplot3d import axes3d
import numpy as np

fig  = plt.figure(figsize=(18, 6))
fig.subplots_adjust(left=0.0, right=1, top=1, bottom=0, wspace=0.08, hspace=0.09)

ax = fig.add_subplot(131)
data = np.genfromtxt('B=4/E_dc=6_mu=116_alpha=0.9496_B=4.0_frame.data.bz2',
                     delimiter=' ', 
                     names=['phi_x', 'phi_y', 'f'])

X, Y, Z = axes3d.get_test_data(0.05)

xi = np.linspace(-3.141, 3.141, num=400)
yi = np.linspace(-4.5, 0.6, num=400)

X, Y = np.meshgrid(xi, yi)
Z = griddata(data['phi_x'], data['phi_y'], data['f'], xi, yi)
plt.pcolor(X, Y, Z, cmap='hot', vmin=0)

ax.xaxis.set_ticks([])
ax.yaxis.set_ticks([])
ax.set_xlim(-3.142,3.142)
ax.set_ylim(-4.5,0.6)
ax.text(-2.6, 0, '(a)', color='white', fontsize=28)

ax = fig.add_subplot(132)
Пример #60
0
fig = plt.figure(figsize=plt.figaspect(0.5))

#piwrwszy wykres
ax1 = fig.add_subplot(1, 2, 1, projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax1.plot_surface(X, Y, Z, cmap=cm.coolwarm, antialiased=False)
ax1.set_zlim(-1.01, 1.01)
fig.colorbar(surf, shrink=0.5, aspect=10)

#drugi wykres
ax2 = fig.add_subplot(1, 2, 2, projection='3d')
X, Y, Z = get_test_data()
ax2.plot_wireframe(Z, Y, Z, rstride=10, cstride=10)

plt.show()
##########################################################

fig = plt.figure()
ax = fig.gca(projection='3d')
x = np.linspace(0, 1, 100)
y = np.sin(x * 2 * np.pi) / 2 + 0.5
ax.plot(x, y, zs=0, zdir='z', label='curve in (x, y)')
colors = ('r', 'g', 'b', 'k')
np.random.seed(19860801)
x = np.random.sample(20 * len(colors))
y = np.random.sample(20 * len(colors))
c_list = []