我使用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) 这个宣言有什么问题?
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; ...}引出警告,而不是像这里处理初始化程序.我不认为这个问题应该作为该问题的副本而结束