绘图表面 - 增强输出

时间:2015-03-01 08:19:41

标签: python matplotlib

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

def figure():
    fig = plt.figure()
    axes = fig.gca(projection='3d')
    x = np.arange(-1.5, 1.5, 0.1)
    y = np.arange(-1.5, 1.5, 0.1)
    x, y = np.meshgrid(x, y)

    f = lambda x, y: 1/np.log(y - (x-1)**0.5)
    axes.plot_wireframe(x, y, f(x, y))
    plt.show()

figure()

如何“缩放”到图中(使其显得更大)? 有没有办法在使用axes.plot_surface时使图形看起来更平滑?

1 个答案:

答案 0 :(得分:0)

在这种情况下,我希望np.linspace超过np.arange

您范围内的许多功能值都很复杂。这些值无法显示。在这里,我使用axes.set_xlimaxes.set_ylim来放大功能的真实部分。

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

def figure():
    fig = plt.figure(figsize=(8,6))
    axes = fig.gca(projection='3d')
    x = np.linspace(-1.5, 1.5, 100)
    y = np.linspace(-1.5, 1.5, 100)
    x, y = np.meshgrid(x, y)

    f = lambda x, y: 1/np.log(y - (x-1)**0.5)
    axes.plot_wireframe(x, y, f(x, y))
    axes.set_xlim(1,1.5)
    axes.set_ylim(0,1.5)

figure()

plot