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

Title for Axes in Basic Dash Graph

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd

df = pd.read_csv(‘gbp_data.csv’)

app=dash.Dash(‘SP-vs-Days’)

gbp_name=df[‘SP’].unique()

app.layout=html.Div(
[
dcc.Graph(id=‘SP-vs-Days(Non-Interactive)’,
figure={
‘data’:[
{‘x’:gbp_name,‘y’:df[‘D1’], ‘name’:‘d1’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D2’], ‘name’:‘d2’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D3’], ‘name’:‘d3’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D4’], ‘name’:‘d4’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D5’], ‘name’:‘d5’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D6’], ‘name’:‘d6’, ‘type’:‘bar’},
{‘x’:gbp_name,‘y’:df[‘D7’], ‘name’:‘d7’, ‘type’:‘bar’}
],
‘layout’:{
#‘yaxis’: ‘Number of issues’,
#‘xaxis’:‘SP’,
‘title’:‘Basic non interactive’
}
}
)
]
)


How do I set individual titles for X-axis and Y-axis in the layout field? Is there any documentation for Graph components like data and layout?

Have you checked https://plot.ly/python/reference/#layout?

Hi thanks for the reply. I checked this link, but if I make the graph as a plotly Bar graph the title of the axes can be specified, but I need to know how to specify the title in the layout of dcc.Graph component. Any idea about what parameters i should add here so that I can do that?

One more doubt , How do i view what all parameters can be given in the layout field of dcc.Graph component? That would be really helpful.

Thanks

Maybe I don´t understand your question. It should be something like:

app.layout=html.Div(
[
dcc.Graph(id='SP-vs-Days(Non-Interactive)',
          figure={
            'data':[
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d1', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d2', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d3', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d4', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d5', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d6', 'type':'bar'},
                    {'x':[1,2,3],'y':[1,2,3], 'name':'d7', 'type':'bar'}
                    ],
            'layout':{
                'title':'Basic non interactive',
                'xaxis':{
                    'title':'SP'
                },
                'yaxis':{
                     'title':'Number of issues'
                }
            }
          }
)])
1 Like

Thanks for the reply. This is what I needed. I also wanted to know whether there is any kind of documnetation for the Graph?

https://plot.ly/python - The plotly.py library and Dash use the same underlying graphing library and share the same syntax. In particular, this page has examples: https://plot.ly/python/figure-labels/

Thanks chriddyp !! :slight_smile: