pyplot:点缀背景和虚线矩形

时间:2016-02-26 19:52:33

标签: python matplotlib

有没有办法获得如下图所示的虚线背景?

enter image description here

我知道的唯一方法是根据这篇文章上传一张点的图片并用该图片填写图:Adding a background image to a plot with known corner coordinates

1 个答案:

答案 0 :(得分:0)

例如,有了这个丑陋的黑客,你可以随时随地找点:

h times

控制import matplotlib.pyplot as plt import numpy as np y = np.random.randn(100) * 100 x = np.arange(len(y)) for xi in x: ybg = np.arange(np.int(y.min())-1, np.int(y.max()+1)) xbg = np.repeat(xi, len(ybg)) plt.plot(xbg, ybg, '.k', alpha = 0.25) plt.plot(x, y, 'b', lw = 3) xbg您可以控制点的绘制位置,这样您就不必考虑图像背景。

相关问题