Quantcast
Channel: ЁЯОЫя╕П Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271
тЖз

Increase figure space outside of plot without making the plot bigger

$
0
0

@Juanouo wrote:

Hi,
Today I was trying to add a note at the bottom of a plot, but iI see it gets cropped, because thereтАЩs no more space for the note to appear, like this (In the bottom left corner you can see the note is cropped off):

I tried using height , but this just makes the plot bigger without adding space outside of it. Also tried with margins and padding , but they donтАЩt seem to work either. So, I guess thereтАЩs another way IтАЩm missing. Any ideas? Anyways hereтАЩs some functional code to reproduce my problem:

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objects as go
from dash.dependencies import Input, Output


app = dash.Dash(__name__)
server = app.server

df = pd.DataFrame(pd.DataFrame({'country': {0: 'Iceland',
  1: 'Bahrain',
  2: 'Norway',
  3: 'Estonia',
  4: 'Switzerland',
  5: 'Israel',
  6: 'Slovenia'},
 'test_million': {0: 102658.70704717531,
  1: 42367.37939352402,
  2: 23969.44609101287,
  3: 23037.322451160784,
  4: 22929.918218991366,
  5: 17042.22280880952,
  6: 16865.661240773756}}))


country_options = [{'label': i, 'value': i} for i in df.country.unique()]

def plot_tests():
    dte = df.sort_values('test_million', ascending=False)[['country', 'test_million']].head(5)
    fig = go.Figure()
    fig.add_trace(go.Bar(x=dte['country'], y=dte['test_million']))
    fig.update_layout(annotations= [dict(
                              x=0.0,
                              y=-0.32,
                              showarrow=False,
                              text="<b>Note</b>: Lorem ipsum .",
                              xref="paper",
                              yref="paper")])
    return fig

app.layout = html.Div(children=[

    dcc.Graph(id='tests', figure=plot_tests())
    ])


if __name__ == '__main__':
    app.run_server(debug=True)

Posts: 2

Participants: 2

Read full topic

тЖз

Viewing all articles
Browse latest Browse all 6271

Trending Articles