绘图表面 - 增强输出

Plotting surface - enhacing the output

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()

我怎样才能"zoom"进入图中(让它看起来更大)? 使用axes.plot_surface代替时,有没有办法让图形看起来更平滑?

在这种情况下,我更喜欢 np.linspace 而不是 np.arange

您范围内的许多函数值都很复杂。无法显示这些值。这里我使用 axes.set_xlim and axes.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()