How to put the legend out of matplotlib plot

I have a series of 20 plots (not subplots) to be made in a single figure. I want the legend to be outside of the box. At the same time, I do not want to change the axes, as the size of the figure gets reduced. Kindly help me for the following queries: I want to keep the legend box outside the plot area. (I want the legend to be outside at the right side of the plot area). Is there anyway

如何将图例从matplotlib图中删除

我有一系列20个地块(不是小插曲)在一个单一的数字。 我希望传奇在盒子外面。 与此同时,我不想改变坐标轴,因为图形的大小会减小。 请帮助我进行以下查询: 我想保留图例区域外的图例框。 (我希望传说在剧情区域的右侧)。 无论如何,我会减小图例框内文本的字体大小,以便图例框的大小很小。 创建字体属性from matplotlib.font_manager import FontProperties fontP = FontProperties() fontP.set_size('small') le

Plot logarithmic axes with matplotlib in python

I want to plot a graph with one logarithmic axis using matplotlib. I've been reading the docs, but can't figure out the syntax. I know that it's probably something simple like 'scale=linear' in the plot arguments, but I can't seem to get it right Sample program: import pylab import matplotlib.pyplot as plt a = [pow(10, i) for i in range(10)] fig = plt.figure() ax = f

在python中用matplotlib绘制对数坐标轴

我想用matplotlib绘制一个对数坐标轴的图形。 我一直在阅读文档,但无法弄清楚语法。 我知道这可能像情节争论中的'scale=linear'那样简单,但我似乎无法做到 示例程序: import pylab import matplotlib.pyplot as plt a = [pow(10, i) for i in range(10)] fig = plt.figure() ax = fig.add_subplot(2, 1, 1) line, = ax.plot(a, color='blue', lw=2) pylab.show() 您可以使用Axes.set_yscale方法。 这允许您

Blobstore Backup Strategy Google App Engine Python

I'm looking for a way to backup the blobstore on Google App Engine to recover from accidental deletion. I'd like to be able to make a backup of the datastore and blobstore at the same time, so that I could recover the entire system. One thing I tried was using Google Cloud Storage for my blobs, and then making backup copies of buckets. However, if I delete a file in the blobstore view

Blobstore备份策略Google App Engine Python

我正在寻找一种方法来备份Google App Engine上的blobstore以从意外删除中恢复。 我希望能够同时对数据存储和blobstore进行备份,以便我可以恢复整个系统。 我尝试过的一件事是使用Google Cloud Storage作为我的blob,然后制作存储桶的备份副本。 但是,如果我在blobstore查看器中删除文件(也会在谷歌云存储中删除它),然后使用gsutil从存储桶备份恢复文件,则blobinfo仍会丢失。 我相信我必须将所有文件路径(Google云存

Google App Engine Locking

just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes the entities. I ran an experiment with 1500 emails, had 1500 entities c

Google App引擎锁定

只是想知道你们中的任何一个人是否遇到过这个问题。 我在Google App Engine上玩弄Python邮件API,并创建了一个应用程序,通过POST接受消息正文和地址,在数据存储中创建一个实体,然后每分钟运行一次cron作业,抓取200个实体并发送删除电子邮件,然后删除实体。 我用1500封电子邮件进行了实验,在数据存储中创建了1500个实体,并发送了1500封电子邮件。 然后我看看我的统计数据,并看到约。 配额中使用了45,000个接收者,这

Python: How to get a value of datetime.today() that is "timezone aware"?

I am trying to subtract one date value from the value of datetime.today() to calculate how long ago something was. But it complains: TypeError: can't subtract offset-naive and offset-aware datetimes The value datetime.today() doesn't seem to be "timezone aware", while my other date value is. How do I get a value of datetime.today() that is timezone aware? Right now it's giv

Python:如何获得datetime.today()的值是“时区感知”?

我正在尝试从datetime.today()的值中减去一个日期值来计算多久以前。 但它抱怨说: TypeError: can't subtract offset-naive and offset-aware datetimes 值datetime.today()似乎不是“时区意识”,而我的其他日期值是。 如何获得datetime.today()的值是可datetime.today()时区的? 现在它给了我当地时间的时间,恰好是PST,即UTC-8小时。 最坏的情况下,有没有办法我可以手动输入datetime.today()返回的datetime对象的时区

Get HTML Source of WebElement in Selenium WebDriver using Python

I'm using the Python bindings to run Selenium WebDriver. from selenium import webdriver wd = webdriver.Firefox() I know I can grab a webelement like so... elem = wd.find_element_by_css_selector('#my-id') And I know I can get the full page source with... wd.page_source But is there anyway to get the "element source"? elem.source # <-- returns the HTML as a string The sel

使用Python在Selenium WebDriver中获取WebElement的HTML源代码

我正在使用Python绑定来运行Selenium WebDriver。 from selenium import webdriver wd = webdriver.Firefox() 我知道我可以像这样抓住一个webelement ... elem = wd.find_element_by_css_selector('#my-id') 我知道我可以得到整个页面的源代码... wd.page_source 但无论如何要获得“元素来源”? elem.source # <-- returns the HTML as a string 用于Python的selenium webdriver文档基本上不存在,并且在代码中看不

Gnocchi Error ImportError: cannot import name build

When I try to execute /usr/bin/gnocchi-api I get following error: Traceback (most recent call last): File "/usr/bin/gnocchi-api", line 6, in from gnocchi.rest.app import build_wsgi_app ImportError: cannot import name build_wsgi_app My gnocchi-api is !/usr/bin/python2.7` #PBR Generated from u'wsgi_scripts' import threading from gnocchi.rest.app import build_wsgi_app if __name_

Gnocchi错误导入错误:无法导入名称构建

当我尝试执行/usr/bin/gnocchi-api 我得到以下错误: Traceback(最近调用最后一个):来自gnocchi.rest.app的第6行的文件“/ usr / bin / gnocchi-api”import build_wsgi_app ImportError:无法导入名称build_wsgi_app 我的gnocchi-api是 !/usr/bin/python2.7` #PBR Generated from u'wsgi_scripts' import threading from gnocchi.rest.app import build_wsgi_app if __name__ == "__main__": import argparse

Scapy TCP RST atack

I tried to write TCP RST atack with Scapy,but my code doesn't work.Please,help me to solve my problem. from scapy.all import * def poison(packet): packet[TCP].flags='RST' sendp(packet) sniff(filter='tcp',prn=poison) There's something wrong with flags ,I think.There's an error: Traceback (most recent call last): File "Univer.py", line

Scapy TCP RST atack

我试图用Scapy编写TCP RST atack,但是我的代码不起作用。请帮助我解决我的问题。 from scapy.all import * def poison(packet): packet[TCP].flags='RST' sendp(packet) sniff(filter='tcp',prn=poison) 我认为flags有问题。有一个错误: 回溯(最近一次通话最后): 文件“Univer.py”,第6行,在sniff(filter ='tcp',prn = poison) 文件“/usr/lib/pymodules/python2.6/s

After installing django in virtual environment, still can't import module

I am trying to use django for web dev, but after I install it, I try to use import it in the interpreter and it says it gives me an import error. Here is what I do. virtualenv venv --distribute source venv/bin/activate so now I am in the virtual environment (venv) pip install django python import django Then I get an ImportError import django Traceback (most recent call last): File "&

在虚拟环境中安装django后,仍然无法导入模块

我正在尝试使用django进行web开发,但是在安装它之后,我尝试在解释器中使用导入,并且它说它给我一个导入错误。 这是我做的。 virtualenv venv --distribute source venv/bin/activate 所以现在我在虚拟环境(venv) pip install django python import django 然后我得到一个ImportError 导入django Traceback(最近一次调用最后一次):ImportError中的第1行的文件“:没有名为'django'的模块import django Trac

How to import and create my class from my module?

I am creating a module, it has the classes: class LogLevel(): Info = 1 Warn = 2 Error = 3 class FalconPeer(): def __init__(self, port=37896, log_level=LogLevel.Info): self._port = port self._log_level = log_level In the folder structure: +---PyFalconUDP | CHANGES.txt | LICENSE.txt | MANIFEST.in | README.txt | setup.py

如何从我的模块导入和创建我的课程?

我正在创建一个模块,它有类: class LogLevel(): Info = 1 Warn = 2 Error = 3 class FalconPeer(): def __init__(self, port=37896, log_level=LogLevel.Info): self._port = port self._log_level = log_level 在文件夹结构中: +---PyFalconUDP | CHANGES.txt | LICENSE.txt | MANIFEST.in | README.txt | setup.py | +---falconu