@Simplorios wrote:
I am trying to build a graph (see below). Above there is free space and I just can not get rid of it. How to deal with this problem. thanks
def create_scatter(x, y, name, xaxis, color): return go.Scatter(x=x, y=y, mode='lines', name=name, xaxis=xaxis, line=dict(color=color)) def create_layout(x_title, range_of_values, showline): x_axis = ['', 'xaxis2', 'xaxis3', 'xaxis4', 'xaxis5', 'xaxis6', 'xaxis7', 'xaxis8'] annotations=[ { 'x':0.5, 'y':round(1-len(x_title)/10+0.1+i/10, 2), 'showarrow':False, 'text':x_title[i], 'xref':"paper", 'yref':"paper", 'font':{ 'color':DEFAULT_COLOR[i] } } for i in range(len(x_title)) ] shapes = [{ 'type': 'line', 'xref':'paper', 'yref': 'paper', 'x0': 0, 'y0': round(1 - len(x_title) / 10 + i / 10, 1), 'x1': 1, 'y1': round(1 - len(x_title) / 10 + i / 10, 1), 'line': { 'color': DEFAULT_COLOR[i], 'width': 2 } } for i in range(len(x_title))] layout = {'xaxis': {'automargin': True, 'side': 'top', 'zeroline': True, 'range': range_of_values[0], 'fixedrange': True}, 'yaxis': {'autorange': 'reversed', 'showline': showline, 'showticklabels': showline, 'domain': [0, 1 - len(x_title)/10]}, 'showlegend': False, 'annotations': annotations, 'shapes': shapes, 'dragmode': 'pan', 'uirevision': True} # 'type': 'date', if len(x_title)>1: b = {x_axis[i]: {'automargin': True, 'anchor': 'free', 'overlaying': 'x', 'side': 'top', 'zeroline': True, 'fixedrange': True, 'range': range_of_values[i], 'position': round(1 - len(x_title) / 10 + i / 10, 1)} for i in range(1, len(x_title))} layout.update(b) return go.Layout(layout) def figure(data_values, settings, show_line): data = [] layout_x = ['x', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7'] for i in range(len(data_values)): data.append(create_scatter(data_values[i][0], data_values[i][1], settings[i][0], layout_x[i], DEFAULT_COLOR[i])) name_x = [] range_of_value = [] for i in settings: name_x.append(i[0]) range_of_value.append(i[1]) layout = create_layout(name_x, range_of_value, show_line) return {'data': data, 'layout': layout}
Posts: 2
Participants: 2