小编Mr *_*pha的帖子

如何阻止条形图隐藏Mathematica中数据值0的标签?

我用它来创建一个条形图:

BarChart[
 Reverse@data,
 BarOrigin -> Left,
 ChartLabels -> 
  Placed[{Reverse@labels, Reverse@data}, {Before, After}],
 ChartElementFunction -> "FadingRectangle"
 ]
Run Code Online (Sandbox Code Playgroud)

有了data = {7, 10, 0, 6, 0, 3, 5}这个

Mathematica图形

问题是某些数据值为0,BarChart甚至不会为它们添加标签.相反,它留下了一个开放空间.即使值为0,我怎样才能使它仍然添加标签?

这是Mathematica 8.

wolfram-mathematica bar-chart mathematica-8

7
推荐指数
1
解决办法
857
查看次数

SQLAlchemy order_by通过关联代理的多对多关系

我在SQLAlchemy的Flask应用程序中使用关联对象设置了多对多的关系.然后,我在类之间设置了关联代理,以提供更直接的访问,而不是通过关联对象.

以下是设置的缩写示例:

class Person(Model):
    __tablename__ = 'persons'
    id = Column(Integer, primary_key=True)
    last_name = Column(Text, nullable=False)
    groups = association_proxy('group_memberships', 'group')
    # Other stuff

class Group(Model):
    __tablename__ = 'groups'
    id = Column(Integer, primary_key=True)
    name = Column(Text, nullable=False)
    members = association_proxy('group_memberships', 'person')
    # Other stuff

class GroupMembership(Model):
    __tablename__ = 'group_memberships'
    id = Column(Integer, primary_key=True)
    person_id = Column(Integer, ForeignKey('persons.id'), nullable=False)
    group_id = Column(Integer, ForeignKey('groups.id'), nullable=False)
    person = relationship('Person', uselist=False, backref=backref('group_memberships', cascade='all, delete-orphan'))
    group = relationship('Group', uselist=False, backref=backref('group_memberships', cascade='all, delete-orphan'))    
    # Other stuff
Run Code Online (Sandbox Code Playgroud)

我不能为我的生活弄清楚如何让返回的成员group.members …

python many-to-many sqlalchemy

6
推荐指数
1
解决办法
1015
查看次数

使用Solve的输出

我有一个数学问题,我解决了这样的问题:

In[1]:= Solve[2x(a-x)==0, x]
Out[1]= {{x->0}, {x->a}}

In[2]:= Integrate[2x(a-x), {x,0,a}]
Out[2]= (a^3)/3

In[3]:= Solve[(a^3)/3==a, a]
Out[3]= {{a->0}, {a->-Sqrt[3]}, {a->Sqrt[3]}}
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果我可以重写它来一步计算它,而不是必须手动输入前一行的结果.我可以使用第二步中的Integrate命令轻松替换第三步中使用的积分.但我无法弄清楚我将如何使用步骤1中的结果作为积分中的积分限制.

wolfram-mathematica

3
推荐指数
1
解决办法
2015
查看次数

getElementsByClassName不是Firefox中的函数

我在GoodReads上的阅读书架是已出版和未出版书籍的混合,很难找到可供阅读的内容.我想我可以把一个GreaseMonkey脚本放在一起,这个脚本会改变尚未发布的书籍条目的背景.

这是我到目前为止所做的:

// ==UserScript==
// @name        Unpublished Lowlighter
// @description Makes the background of books not yet published on the Goodreads to-read shelf grey.
// @include     http://www.goodreads.com/*
// ==/UserScript==

function dateColor() {
    var books = document.getElementsByClassName('bookalike review');
    for (var book in books) {
        var dateString = book
                        .getElementsByClassName('field date_pub')
                        .getElementsByClassName('value')
                        .textContent;
        var date = new Date(dateString);
        var today = new Date();
        if (date > today) {
            book.style.backgroundColor('Lightgrey');
        }
    }
}

dateColor();
Run Code Online (Sandbox Code Playgroud)

问题是它不起作用.当我尝试在暂存器中运行脚本时,它给出了错误:Exception: book.getElementsByClassName is not a function

我认为Firefox支持getElementsByClassName …

javascript firefox greasemonkey

2
推荐指数
1
解决办法
4万
查看次数