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

Getting the final plotly slider value

Hello Dach Communey,

I am new to plotly and django. I am tring to algin two heatmaps on top of each other using two plotly slider (one for the x direction and the other for the y direction).
I am wondering if there is a way to get the value of the slider after the user finish the manual alginment to a requestr.POST so it can be saved in a django model.

my django view (just an example)

def alginview(request, pk):
if request.method==‘GET’:
x = np.arange(-200,201)
y = np.arange(-200,201)
z1 = np.zeros([401,401])
z2 = np.zeros([401,401])
z1[200:300,200:300]=1
z2[200:300,210:310]=1
config={‘modeBarButtonsToRemove’: [‘sendDataToCloud’,‘toImage’,‘select2d’,‘lasso2d’], ‘displaylogo’: False}
h1 = dict(z = z1, x = x, y = y, type = ‘heatmap’, colorscale = ‘Cividis’, showscale =False, name=‘predicted’, opacity=1.0)
h2 = dict(z = z2, x = x, y = y, type = ‘heatmap’, colorscale = ‘Reds’, showscale =False, name=‘measured’, opacity=0.5)
steps_x = []
steps_y = []
ii = np.arange(-100,101)
for i in ii:
step_x = dict(method = ‘restyle’,args = [‘x’, [x,x-(1i)]], label = ‘%.1f’ %(i))
steps_x.append(step_x)
step_y = dict(method = ‘restyle’,args = [‘y’, [y,y-(1
i)]], label = ‘%.1f’ %(i))
steps_y.append(step_y)

    sliders = [dict(active = 100, currentvalue = {"prefix":'x offset:'}, pad = {"t": 20},
                steps = steps1, len =0.5, x = 1.1, y=0.5),
           dict(active = 100, currentvalue = {"prefix":'y offset:'}, pad = {"t": 20},
                steps = steps1, len =0.5, x = 1.1, y=0.75)]
    layout = dict(xaxis=dict(title='x [cm]'), yaxis=dict(title='y [cm]'),sliders=sliders ,width = 800, height = 600)
    figure = dict(data=[h1,h2],layout=layout)
    plot = plotly.offline.plot(figure, auto_open=False, output_type='div',show_link=False, include_plotlyjs=False,config=config)
    return render(request,'app/alginpage.html', plot)        
elif request.method=='POST':
    pass
    #here I need to get the slider value so I can save it in a django model.