Shared x axis - titles and scale not shown in all subplots


#1

hi

How can i force to show the x title, scale and ticks in all subplots with shared x axis?

the code I’ve developed below only shows in the top plot

thanks

#! /usr/bin/python3.6
# -*- coding: utf-8 -*-
#Ricardos.geral@gmail.com

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from plotly.graph_objs import *
import os

interval = 3*1000 # mseconds

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

app.layout = html.Div([
    html.Div([
        html.H2("Sensor live data"),
    ], className='banner'),

    html.Div([
        html.Div([
            html.H6(data) # place filename and path of the csv file
        ], className='Title'),
    ], className='row wind-speed-row'),

    html.Div([
        html.Div([
            html.H3("Plots")
        ], className='Title'),
        html.Div([
            dcc.Graph(id='plots'),
        ], className='row'),

        dcc.Interval(id='data-update', interval=interval, n_intervals=0),
    ], className='row wind-speed-row'),

],
    style={'padding': '0px 10px 15px 10px',
          'marginLeft': 'auto', 'marginRight': 'auto', "width": "900px",
          'boxShadow': '0px 0px 5px 5px rgba(204,204,204,0.4)'})


@app.callback(Output('plots', 'figure'), [Input('data-update', 'n_intervals')])
def plots(interval):

    flow = Scatter(
        x=[0,1,2,3,5],
        y=[1,3,8,2,5],
        name='Flow rate ',
        mode='lines+markers',
        line=Line(color='blue'),
        marker=Marker(color='blue'),
        legendgroup= 'flowmeter',
    )

    up_press = Scatter(
        x=[0,1,2,3,5],
        y=[9,0,7,4,8],
        name='Ups pressure',
        line=Line(color='blue'),
        mode='lines',
        xaxis = 'x',
        yaxis='y2',
        legendgroup='pressures',
    )
    traces = [flow, up_press]


    layout = Layout(
        height=1000,
        xaxis=dict(
            autorange=True,
            rangemode='nonnegative',
            autotick=True,
            ticks='inside',
            tick0=0,
            dtick=1,
            showticklabels=True,
            title='Duration (min)',
            showaxeslabels=True,
            mirror='allticks',
        ),
        yaxis=dict(
            autorange=True,
            title='Flow rate (l/min)',
            domain =[0.55,1]
        ),
        yaxis2=dict(
            autorange=True,
            showline=False,
            fixedrange=False,
            zeroline=False,
            title='pressure (mmH2O)',
            domain=[1, 0.45]
        ),

        legend = dict(x=0.05,y=5.5, orientation="h"),

    )

    return Figure(data=traces, layout=layout)


external_css = ["https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css"]

for css in external_css:
    app.css.append_css({"external_url": css})

if 'DYNO' in os.environ:
    app.scripts.append_script({
        'external_url': 'https://cdn.rawgit.com/chriddyp/ca0d8f02a1659981a0ea7f013a378bbd/raw/e79f3f789517deec58f41251f7dbb6bee72c44ab/plotly_ga.js'
})

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

#2

Hi there,

Unfortunately it’s not possible to show the axis multiple times while shared. You could create these subplots without a shared x axis, and just manually make sure they’re in the same domain.


#3

You could also add your own text w custom annotations