Combo Bar/Scatter Plot Axis & Fill Issues

Hi, I have 2 issues when trying to plot a Combo Bar/Scatter plot. I’m not sure pasting my code will help much since it’s quite convoluted and there are other functions used. Anyway, here it is:

def sus_chart(start_date, end_date, day, week, month, view, group):
    start_date, end_date, date_group = date_process(start_date, end_date, day, week, month)
    
    signups = sus_fetch(start_date, end_date, date_group, group)
    signups = refactor_dt_df(signups, 'date', start_date, end_date, date_group, group_col='grp')
    signups = gen_cnst_df(signups, 'date', 'count')
    
    if group == 'signup_type':
        signups_net = signups.groupby('x')['y'].sum().reset_index()
        signups_net['group'] = 'Net Signups'
        chart_y_axis = 'Signup / Cancellation Count'
        signup_cmap = {'New Signups': 'emerald', 'Return Signups': 'peter_river', 'Cancellations': 'alizarin',
                       'Expiries': 'carrot', 'Net Signups': 'midnight_blue'}
        colour_map = {k:colour_dict[v] for k,v in signup_cmap.items()}
        signups_net_params = {'mode': 'lines+markers', 'fill': 'tozerox', 'fillcolor': 'rgba(44, 62, 80, 0.3)', 'line': {'shape': 'hvh'}}
        traces = gen_traces(signups, 'bar', colour_map=colour_map)
        traces.extend(gen_traces(signups_net, 'scatter', colour_map=colour_map, custom_params=signups_net_params))
    else:
        chart_y_axis = 'Signup Count'
        colour_map = {}
        traces = gen_traces(signups, 'bar', colour_map=colour_map)
    
    df_shape = (signups['x'].max() - signups['x'].min()).days / date_group_map[date_group]
    
    return {
        'data': traces,
        'layout': dict(
            barmode='relative', legend=legend_dict, font=font_dict, margin=margin_dict,
            xaxis=gen_ts_xaxis(df_shape, date_group, start_date),
            yaxis=dict(title=chart_y_axis)
        )
    }

Executing that results in the following:

Two issues here:

  1. The date/x axis has an additional day added to each end. This doesn’t occur if I don’t include the Scatter trace data
  2. The fill tozerox doesn’t fill to the correct point

Any help would be much appreciated. Hope everything’s clear.

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online