负高度的绘图序列徽标

时间:2018-07-09 08:16:32

标签: python matplotlib dna-sequence

我正在从matplotlib.text模块中使用TextPath绘制文本。我部分使用了this thread中的代码,并以负高绘制。除了将负高度绘制的代码垂直翻转之外,它的效果非常好。虽然这对于“ A”或“ T”来说都不是问题。 “ C”尤其是“ G”看起来很奇怪:letters plotted with negative height, they are horizontally flipped

有没有一种方法可以垂直翻转文本? 这是代码的一部分,尽管大部分是从the thread mentioned above

复制而来
select p0.*
from post p0 
join post p1 on p0.category= p1.category
join
(
    select p2.category, max(p2.views) as max_views
    from post p2
    group by p2.category
) p2 on p2.category= p1.category and 
        p2.max_views = p1.views and
        p1.id > 4
order by p2.max_views desc, p0.vview desc

1 个答案:

答案 0 :(得分:0)

ImportanceOfBeingErnest向我指出了解决方案: 它既不是字母的翻转也不是高度为负的图,而只是改变y值而已,图开始于:

fig, ax = plt.subplots(figsize=(10,3))
x = 1.0
maxi = 2
for scores in all_scores:
#sort the scores with "reverse=True" so most important letters are at the bottom
    scores=sorted(scores,key=operator.itemgetter(1),reverse=True)
#start plotting at the negative sum of all values below 0
    y = np.sum([-1*s[1] for s in scores])
    for base, score in scores:
        letterAt(base, x,y, score, ax)
        y += score
    x += 1
    maxi = max(maxi, y)


plt.xticks(np.arange(1,x))
plt.xlim((0, x)) 
plt.ylim((-2, maxi)) 
plt.tight_layout()      
plt.show()

enter image description here