Мои узлы Graphviz находятся друг над другом - PullRequest
0 голосов
/ 23 апреля 2020

Я хочу создать граф с графиком и python с большим количеством узлов. Но он отображается поверх друг друга, и я не могу понять, как исправить интервал между графиками.

Вот вывод:

Output

А вот мой код, в котором я генерирую узлы:

def build_mind_map(history, site_info):
mind_map = Graph('mind_map', filename='graph', engine='sfdp', strict=True)
mind_map.graph_attr = {'label': heading, 'labelloc': "t", "labelfontsize": '13.0', "labeljust": "l"}
mind_map.graph_attr.update(size="2,2")
sorted_list = sort_list(site_info)
nodes_list_0 = []
nodes_list_1 = []
g = sorted_list[0]
nodes_list_0.append(str(g[0]))
mind_map.attr('node', color='cyan4', style='filled', labelfontsize="20", pad='10')
mind_map.node(str(g[0]), label="<<font point-size='18'><B>" + g[0] + "</B></font><br/><br/>>", nodesep="2")
for j in sorted_list:
    date_string = '\n'
    for d in j[2]:
        date_string = date_string + "\n" + d
    if str(j[0]) not in nodes_list_0:
        mind_map.attr('node', color='crimson', style='filled', pad='10')
        mind_map.node(str(j[0]), label="<<B>" + j[0] + "</B><br/><br/>" + date_string + ">", nodesep="2")
        nodes_list_0.append(str(j[0]))
    if str(j[1]) not in nodes_list_1:
        mind_map.attr('node', color='cyan3', style='filled', pad='10')
        mind_map.node(str(j[1]), label="<<B>" + j[1] + "</B><br/><br/>" + date_string + ">")
        nodes_list_1.append(str(j[1]))
    mind_map.edge(str(j[0]), str(j[1]))
mind_map.edge(str(g[0]), str(g[1]))
    if history == "1":
    mind_map_second = Graph('mind_map', filename='graph', engine='sfdp')
    mind_map_second.attr('node', color='yellow', style='filled', labelfontsize="20")
    for i in db.get_history_matches():
        m = i[3].split(",")
        info_string = ""
        try:
            if len(m[0]) > 0:
                info_string += "<br/>Branch: " + m[0]
        except:
            pass
        try:
            if len(m[1]) > 0:
                info_string += "<br/>Driver: " + m[1]
        except:
            pass
        try:
            if len(m[2]) > 0:
                info_string += "<br/>Location" + m[2]
        except:
            pass
        try:
            if len(m[3]) > 0:
                info_string += "<br/>Date: " + m[3]
        except:
            pass
        try:
            if len(m[4]) > 0:
                info_string += "<br/>CIS: " + m[4]
        except:
            pass
        try:
            if len(m[5]) > 0:
                info_string += "<br/>CAS: " + m[5]
        except:
            pass
        if str(i[0]) not in nodes_list_0:
            mind_map_second.node(str(i[0]), label="<History Found<br/><br/><B>" + i[0] + "</B><br/>" + info_string + ">")
            nodes_list_0.append(str(i[0]))
        if str(i[1]) not in nodes_list_1:
            mind_map_second.node(str(i[1]), label="<History Found<br/><br/><B>" + i[1] + "</B><br/>" + info_string + ">")
            nodes_list_1.append(str(i[1]))
        mind_map_second.edge(str(i[0]), str(i[1]))
mind_map.subgraph(mind_map_second)
mind_map.view()

Может кто-нибудь помочь мне разобраться, как отсортировать интервалы.

Спасибо

...