how to fix series legend?

I'm trying to create an interactive plotly graph from pandas dataframes. However, I can't get the legends displayed correctly. Here is a working example: import pandas as pd import numpy as np import matplotlib.pyplot as plt import plotly.plotly as py # sign into the plotly api py.sign_in("***********", "***********") # create some random dataframes dates = pd.date_range('1/1/2000'

如何修复系列图例?

我试图从熊猫数据框中创建一个交互式的图解图。 但是,我无法正确显示图例 。 这是一个工作示例: import pandas as pd import numpy as np import matplotlib.pyplot as plt import plotly.plotly as py # sign into the plotly api py.sign_in("***********", "***********") # create some random dataframes dates = pd.date_range('1/1/2000', periods=8) df1 = pd.DataFrame(np.random.randn(8, 1), index=dates, co

python matplotlib blit to axes or sides of the figure?

I'm trying to refresh some plots that I have within a gui everytime I go once through a fitting procedure. Also, these plots are within a framw which can be resized, so the axes and labels etc need to be redrawn after the resizing. So was wondering if anyone knew how to update the sides of a figure using something like plot.figure.canvas.copy_from_bbox and blit . This appears to only copy

蟒蛇matplotlib blit轴或图的两侧?

每次我通过一个合适的程序时,我都试图刷新一些gui中的情节。 此外,这些图是在一个可以调整大小的框内,所以轴和标签等需要在调整大小后重新绘制。 所以想知道是否有人知道如何使用像plot.figure.canvas.copy_from_bbox和blit这样的东西来更新图形的边。 这似乎只复制图形区域(绘制线条的位置)的背景,而不是图形或图形的两侧(标签和刻度)。 我一直试图通过反复试验和阅读mpl文档来更新我的图表,但到目前为止,我的代

Get colors of current gtk style

I use PyGTK and I want to get colors of a widget (for example bg color), I run such a code: gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257) widget = gtk.HBox() ## for example style = widget.get_style() for i in range(5): print i, gdkColorToRgb(style.bg[i]) But it does not give colors of my current gtk theme(style). It seems to be for default gtk theme (my current them

获取当前gtk风格的颜色

我使用PyGTK,我想获得一个小部件的颜色(例如bg颜色),我运行这样的代码: gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257) widget = gtk.HBox() ## for example style = widget.get_style() for i in range(5): print i, gdkColorToRgb(style.bg[i]) 但它并没有给我目前的gtk主题(风格)的颜色。 它似乎是默认的gtk主题(我目前的主题是黑暗的,而这段代码给出了浅色)我使用ArchLinux和PyGT

How do I download a file over HTTP using Python?

I have a small utility that I use to download a MP3 from a website on a schedule and then builds/updates a podcast XML file which I've obviously added to iTunes. The text processing that creates/updates the XML file is written in Python. I use wget inside a Windows .bat file to download the actual MP3 however. I would prefer to have the entire utility written in Python though. I struggl

如何使用Python通过HTTP下载文件?

我有一个小工具,用于从网站上按计划下载MP3,然后构建/更新我明显添加到iTunes中的播客XML文件。 创建/更新XML文件的文本处理是用Python编写的。 我在Windows .bat文件中使用wget来下载实际的MP3。 我宁愿用Python编写整个实用程序。 我尽力找到一种方法来实际下载Python中的文件,因此我使用了wget 。 那么,如何使用Python下载文件? 在Python 2中,使用标准库附带的urllib2。 import urllib2 response = urllib2.u

Dealing with JSON with duplicate keys

If I have JSON with duplicate keys and different values in each of the duplicate keys, how can I extract both in python? ex: { 'posting': { 'content': 'stuff', 'timestamp': '123456789' } 'posting': { 'content': 'weird stuff', 'timestamp': '93828492' } } If I wanted to grab both timestamps, how w

使用重复键处理JSON

如果我在每个重复键中都有重复键和不同值的JSON,如何在python中提取这两个键? 例如: { 'posting': { 'content': 'stuff', 'timestamp': '123456789' } 'posting': { 'content': 'weird stuff', 'timestamp': '93828492' } } 如果我想抓住时间戳,我会怎么做? 我尝试了一个a = json.loads(json_str) ,然后a['

Need Example of passing Jasper Reports Parameters for REST v2 API using JSON

When I look at the documentation for passing parameters to the Jasper Report REST 2 API here: http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v550/running-report-asynchronously I see that I need to have a "parameters" dict. The example in the link shows the XML which is not all that useful since it's unclear exactly what the equivalent JSON sho

需要使用JSON为REST v2 API传递Jasper报表参数的示例

当我查看将参数传递给Jasper Report REST 2 API的文档时:http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v550/running-report-asynchronously我看到我需要一个“参数”字典。 链接中的示例显示了XML并不是那么有用,因为它不清楚等效的JSON应该是什么样子。 我能找到的最近的是这个链接:http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56

Why is pandas '==' different than '.eq()'

Consider the series s s = pd.Series([(1, 2), (3, 4), (5, 6)]) This is as expected s == (3, 4) 0 False 1 True 2 False dtype: bool This is not s.eq((3, 4)) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) ValueError: Lengths must be equal I was under the assumption they were the

为什么熊猫'=='不同于'.eq()'

考虑系列s s = pd.Series([(1, 2), (3, 4), (5, 6)]) 这是预期的 s == (3, 4) 0 False 1 True 2 False dtype: bool 这不是 s.eq((3, 4)) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) ValueError: Lengths must be equal 我假设他们是一样的。 他们有什么区别? 文件说什么? 相当于系列

Can you optimize imports in functions using closures?

These two questions concern using import inside a function vs. at the top of a module. I do not need to be convinced to put my imports at the top, there are good reasons to do that. However, to better understand the technical issues I would like to ask a followup. Can you get the best of both worlds performance-wise by using a closure and only importing on first run of the function? Specifi

你可以使用闭包优化进口函数吗?

这两个问题涉及使用函数内部的import与模块顶部的import 。 我不需要说服我把进口放在首位,这是有充分理由的。 但是,为了更好地理解技术问题,我想问一个后续问题。 你可以通过使用闭包并仅在函数的第一次运行时导入两个世界中最好的性能? 具体来说,假设你有如下代码: import sys def get_version(): return sys.version 你想要导入只发生在函数被调用时,所以你把它移到里面: def get_version(): import

Is there an interactive graphing library for python

I'm looking for an interactive graphing library for Python. By "graph", I meant a set of nodes connected by a set of vertices (not a plot of values over xy axis, nor a grid of pixels). By "interactive", I meant I can drag-and-drop the nodes around and I need to be able to click on the nodes/vertices and have the library pass the nodes/vertices to my callbacks, which ma

是否有Python的交互式图形库

我正在寻找Python的交互式图形库。 通过“图形”,我的意思是通过一组顶点连接的一组节点(不是xy轴上的值图,也不是像素网格)。 通过“交互式”,我的意思是我可以拖放节点周围,我需要能够点击节点/顶点,并让库传递节点/顶点到我的回调,这可能会添加/删除节点/顶点或显示信息(由于数据集太大/很复杂,我无法在启动时加载完整的图形;相反,我将根据用户输入只加载必要的数据切片)。 通过Python,我的意思是编程语言Pytho

Python Graph Library

I'm writing a python application that will make heavy use of a graph data structure. Nothing horribly complex, but I'm thinking some sort of graph/graph-algorithms library would help me out. I've googled around, but I don't find anything that particularly leaps out at me. Anyone have any good recommendations? There are two excellent choices: NetworkX and igraph I lik

Python图形库

我正在编写一个将大量使用图数据结构的python应用程序。 没有什么可怕的复杂,但我想某种图/图算法库会帮助我。 我一直在搜索,但我没有发现任何特别突出的东西。 任何人有什么好的建议? 有两个很好的选择: NetworkX 和 IGRAPH 我喜欢NetworkX,但我也读过关于igraph的好东西。 我经常使用带有100万个节点的图表,没有任何问题(这是大小为V + E的字典的开销的两倍) 如果您需要功能比较,请参阅Networkx-dis