相关疑难解决方法(0)

建议的绘图方式是:matplotlib还是pylab?

我看到我可以用Python 绘图:

import matplotlib
matplotlib.pyplot.plot(...)
Run Code Online (Sandbox Code Playgroud)

要么:

import pylab
pylab.plot(...)
Run Code Online (Sandbox Code Playgroud)

这两个都使用相同的matplotlib绘图代码.

那么,Python社区推荐哪一种作为更好的绘图方法呢?为什么?

python matplotlib

83
推荐指数
2
解决办法
3万
查看次数

如何将pyplot函数附加到图形实例?

以前,我遇到了多个Matplotlib数字之间干扰的问题.最后,我跟踪了一个问题,即某些pyplot函数没有附加到它们的图形实例,但可以在其他一些并行创建的图形实例中呈现.

这是一些示例代码:

from django.http import HttpResponse
from numpy import arange, meshgrid
from matplotlib.mlab import bivariate_normal

def show_chart(request):
    delta = 0.025
    x = arange(-3.0, 3.0, delta)
    y = arange(-2.0, 2.0, delta)
    X, Y = meshgrid(x, y)
    Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
    Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
    Z = 10.0 * (Z2 - Z1)

    from matplotlib.pyplot import figure, contour
    fig1 = figure(figsize=(4, 4), facecolor='white')
    contour(X, Y, Z)

    response = HttpResponse(content_type='image/png')
    fig1.savefig(response, format='png')
    fig1.clear()
    return …
Run Code Online (Sandbox Code Playgroud)

python numpy matplotlib

11
推荐指数
2
解决办法
5157
查看次数

标签 统计

matplotlib ×2

python ×2

numpy ×1