Black Lives Matter. Please consider donating to Black Girls Code today.

Сhart size problem

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']
       {   'x':0.5,
           'y':round(1-len(x_title)/10+0.1+i/10, 2),
       for i in range(len(x_title))
   shapes = [{
       'type': 'line',
       '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))}
   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:
   layout = create_layout(name_x, range_of_value, show_line)
   return {'data': data, 'layout': layout}


If you are talking about the free space above the title, you could change the padding and/or margin assoc. with the figure

1 Like