我更喜欢使用matplotlibOOP风格:
f, axarr = plt.subplots(2, sharex=True)
axarr[0].plot(...)
axarr[1].plot(...)
Run Code Online (Sandbox Code Playgroud)
这样可以更轻松地跟踪多个图形和子图.
问题:如何使用seaborn这种方式?或者,如何将此示例更改为OOP样式?如何将seaborn绘图函数描述为lmplot哪个Figure或哪个Axes绘图?
我正在尝试加载/usr/share/matplotlib/sample_data/goog.npy:
datafile = matplotlib.cbook.get_sample_data('goog.npy', asfileobj=False)
np.load(datafile)
Run Code Online (Sandbox Code Playgroud)
它在Python 2.7中很好,但在Python 3.4中引发了异常:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd4 in position 1: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
我认为它与bytes/str/unicodePython 2和3之间的不一致有关,但不知道如何通过.
题:
.npy从Python 3中的Python 2 加载文件(NumPy数据)?写作Python 2,我总是使用xrange,但它在Python 3中重命名.所以我主要是写
if sys.version.startswith('3'):
zrange = range
else:
zrange = xrange
Run Code Online (Sandbox Code Playgroud)
并zrange在下面使用.是否有更优雅的解决方案(不依赖于第三方包装),from __future__ import unicode_literal希望如此?
在**为运营商numpy.matrix不支持非整数次幂:
>>> m
matrix([[ 1. , 0. ],
[ 0.5, 0.5]])
>>> m ** 2.5
TypeError: exponent must be an integer
Run Code Online (Sandbox Code Playgroud)
我想要的是
octave:14> [1 0; .5 .5] ^ 2.5
ans =
1.00000 0.00000
0.82322 0.17678
Run Code Online (Sandbox Code Playgroud)
我可以做到这一点numpy还是scipy?
这不是元素操作.正如本文所述,这是一个提升到一定功率的矩阵(在线性代数中).
试图阅读Scrapy的代码.scaper,crawler和spider这两个词令人困惑.例如
scrapy.core.scraper
scrapy.crawler
scrapy.spiders
Run Code Online (Sandbox Code Playgroud)
任何人都可以在Scrapy的背景下解释这些术语的含义和差异吗?提前致谢.
我试图继承xrange(使用in以及迭代来实现成员资格测试)。但我收到以下错误消息:
TypeError: Error when calling the metaclass bases
type 'xrange' is not an acceptable base type
Run Code Online (Sandbox Code Playgroud)
有什么特别之处xrange?
我一直很好奇什么
admin.autodiscover()
Run Code Online (Sandbox Code Playgroud)
实际上做。该文件没有对此进行过多说明:
上面我们使用 admin.autodiscover() 自动加载 INSTALLED_APPS admin.py 模块。
和
使用您自己的 AdminSite 实例时实际上没有必要使用自动发现,因为您可能会在 myproject.admin 模块中导入所有每个应用程序的 admin.py 模块。
如果我不解开
# admin.autodiscover()
Run Code Online (Sandbox Code Playgroud)
我会失去什么功能?
我应该出于什么考虑使用或不使用 autodiscover?
尝试实施Needleman-Wunsche算法进行生物序列比较.在某些情况下,存在多个最佳编辑路径.
生物seq比较工具处理此问题的常见做法是什么?替换/插入/删除中的任何优先级/首选项?
如果我想在内存中保留多个编辑路径,建议使用任何数据结构?或者一般来说,如何存储分支和合并的路径?
任何评论赞赏.
使用matplotlib时:
from matplotlib import pyplot as plt
figure = plt.figure()
ax = figure.add_subplot(111)
ax.plot(x,y)
figure.show() # figure is shown in GUI
# How can I view the figure again after I closed the GUI window?
figure.show() # Exception in Tkinter callback... TclError: this isn't a Tk application
figure.show() # nothing happened
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
如果调用了Figure.show(),如何获取上一个图?
figure.add_suplot(111)如果我有多个数字,因此from pylab import *; plot(..); show()似乎不是我正在寻找的解决方案,是否有更方便的替代方法。
我渴望的是
showfunc(stuff) # or
stuff.showfunc()
Run Code Online (Sandbox Code Playgroud)
其中stuff是一个对象,其中包含布置在一张图片中的所有图,并且showfunc是无状态的(我是说,每次调用它时,我的行为就像第一次调用一样)。与之合作时可能matplotlib吗?
如果我键入以下两个命令:
i=1
var$i=2014
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息var1=2014: command not found.
我已经找到了如何declare在这篇 SO帖子中创建动态变量名称,但我仍然想知道为什么会生成错误消息.它意味着bash被var1=2014视为命令/可执行文件名而不是赋值,并且if this line is an assignment测试发生在$i扩展之前.
Qustion:
bash在解析输入行wrt赋值后遵循什么顺序?
任何推荐的阅读也不胜感激.
python ×7
matplotlib ×2
numpy ×2
bash ×1
django ×1
inheritance ×1
matrix ×1
oop ×1
python-3.x ×1
scipy ×1
scrapy ×1
seaborn ×1
typeerror ×1
web-crawler ×1
xrange ×1