小编fat*_*k92的帖子

Matplotlib - 为什么条形图线条颜色是黑色的?

我使用Matplotlib来绘制浮动列表.如果我的列表长度为100个浮点数,则图表会显示正确的颜色.但如果列表长785浮点数,那么它只显示黑色.这是代码.

import numpy as np
import matplotlib.pyplot as plt
import Image

Consensus = []
Prediction = []
Final = []
for line in open('1.out').readlines():
    words = line.split()
    Consensus.append(float(words[10]))
    Prediction.append(int(words[11]))

for i,j in zip(Consensus,Prediction):
    Final.append(i*j)

max_score = 3
length = 785
ind = np.arange(length)    # the x locations for the groups
width = 1       # the width of the bars: can also be len(x) sequence

p1 = plt.bar(ind, Consensus, width, color='red')
p2 = plt.bar(ind, Final, width, color='blue')

plt.ylabel('Scores')
plt.title('Scores by group …
Run Code Online (Sandbox Code Playgroud)

python colors matplotlib bar-chart

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

Char*string []声明错误

这个宣言有什么问题?

char *add_element[] = {"1","S"};
Run Code Online (Sandbox Code Playgroud)

编译时我得到这个错误 -

warning: initialization discards qualifiers from pointer target type
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

这个问题与我为什么不同; 使用'const char*'类型的表达式初始化'char*'会丢弃限定符?.这可以通过下面的评论来验证.谢谢你的回答.

可能重复的问题是相关的,但不一样.这是为什么void func(const char*ptr){char*local = ptr; ...}引出警告,而不是像这里处理初始化程序.我不认为这个问题应该作为该问题的副本而结束

c pointers char

5
推荐指数
1
解决办法
251
查看次数

标签 统计

bar-chart ×1

c ×1

char ×1

colors ×1

matplotlib ×1

pointers ×1

python ×1