我正在尝试根据我使用的每日时间跟踪文件制作时间跟踪图表.我编写的代码可以抓取我的文件并生成一些列表.
endTimes是特定活动以月为单位的时间列表,从月份的第一天午夜0开始到一个月内的多分钟.
labels是endTimes中列出的时间的标签列表.由于跟踪器在0分钟之前没有任何数据,因此它比结束时间短.大多数标签都是重复的.
类别包含标签的每个唯一值,以便我对时间的看法.
我想创建一个颜色条或一堆颜色条(每天1个),这些颜色条将描述我如何花费一个月的时间并将颜色与每个标签相关联.类别中的每个值都将具有关联的颜色.更蓝更好.更多的红色更糟糕.已经是为了使jet colormap正确,但是我需要为类别中的每个值均匀地分隔出亵渎的颜色值.然后我想下一步是将其转换为列出的色彩映射,以根据与类别关联的标签的方式用于色条.
我认为这是正确的做法,但我不确定.我不确定如何将标签与颜色值相关联.
到目前为止,这是我的代码的最后一部分.我找到了一个函数来制作一个离散的色彩图.它确实如此,但它不是我想要的,我不确定发生了什么.
谢谢您的帮助!
# now I need to develop the graph
import numpy as np
from matplotlib import pyplot,mpl
import matplotlib
from scipy import interpolate
from scipy import *
def contains(thelist,name):
# checks if the current list of categories contains the one just read
for val in thelist:
if val == name:
return True
return False
def getCategories(lastFile):
'''
must determine the colors to use
I would like to make a gradient so that …
Run Code Online (Sandbox Code Playgroud) 我正在研究一个在我自己的类中使用multimaps的项目,我遇到了一个段错误.以下是我的代码中与该问题相关的部分.我真的很感激一些帮助.谢谢.
这是database.h
#include <iostream>
#include <map>
using namespace std;
class database{
public:
database(); // start up the database
int update(string,int); // update it
bool is_word(string); //advises if the word is a word
double prox_mean(string); // finds the average prox
private:
multimap<string,int> *data; // must be pointer
protected:
};
Run Code Online (Sandbox Code Playgroud)
这是database.cpp
#include <iostream>
#include <string>
#include <map>
#include <utility>
#include "database.h"
using namespace std;
// start with the constructor
database::database()
{
data = new multimap<string,int>; // allocates new space for the database …
Run Code Online (Sandbox Code Playgroud)