在Linux上使用可滚动的x(时间/水平)轴绘制数据

时间:2015-06-23 11:36:05

标签: python r matplotlib plot scipy

我想绘制x轴长的数据。如果我绘制整个x轴,那么绘图会缩小,几乎不可读。我在SO上找到了this回答,它指向following scipy / matplotlib代码。但是当我尝试运行上面提到的代码时,我得到以下错误:

Traceback (most recent call last):
  File "scrollingPlot.py", line 88, in <module>
    app = MyApp()
  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8628, in __init__
    self._BootstrapApp()
  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 8196, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File "scrollingPlot.py", line 82, in OnInit
    self.frame = MyFrame(parent=None,id=-1)
  File "scrollingPlot.py", line 21, in __init__
    self.scroll_range)
  File "/usr/lib/python2.7/dist-packages/wx-3.0-gtk2/wx/_core.py", line 11226, in SetScrollbar
    return _core_.Window_SetScrollbar(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "sb" failed at ../src/gtk/window.cpp(4754) in SetScrollbar(): this window is not scrollable

PS:也欢迎其他解决方案(最好是python,R,或简单和多平台的东西)

PPS:我已经为提到的错误打开了issue

2 个答案:

答案 0 :(得分:11)

您是否考虑过使用matplotlib slider widgets

这里只是一个代码示例

var total = 0;
$(".plz3").each(function(){
total += Number(Number($(this).text().trim().match(/\((\d+)\)/)[1]));
});

答案 1 :(得分:0)

R this answer可以帮到你。它会将绘图另存为单独的png,但您可以使用其他命令更改格式类型。该答案的相关代码再现:

 png("wide.png", width = 1e5, height = 500)
 plot((sin(1:10000/100)+rnorm(10000)/5),type='l')
 dev.off()
 #bmp("wide.bmp", width = 1e5, height = 500)
 #plot((sin(1:10000/100)+rnorm(10000)/5),type='l')
 #dev.off()
 #note that the png has a size of 396 KB, while the bmp has 48,830 KB.