Skip to content

Commit

Permalink
Merged origin/bnu_figupdates
Browse files Browse the repository at this point in the history
  • Loading branch information
ascillitoe committed Jul 16, 2021
2 parents e2d35e0 + 0dc1b09 commit 1b7520a
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions apps/Analytical.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,19 @@
ticks='outside',
zerolinecolor="white")

xparams = params.copy()
xparams['title'] = 'X1'
yparams = params.copy()
yparams['title'] = 'X2'
zparams = params.copy()
zparams['title'] = r'f(x)'

layout = dict(margin={'t': 0, 'r': 0, 'l': 0, 'b': 0, 'pad': 10}, autosize=True,
scene=dict(
aspectmode='cube',
xaxis=params,
yaxis=params,
zaxis=params,
xaxis=xparams,
yaxis=yparams,
zaxis=zparams,
),
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)'
Expand Down Expand Up @@ -1142,22 +1149,8 @@ def Plot_poly_3D(ModelSet, n_clicks, true_vals, param_num,ndims,fig):
print('ModelSet',ModelSet)
if (ModelSet is not None):
if ndims==2:
layout = dict(margin={'t': 0, 'r': 0, 'l': 0, 'b': 0, 'pad': 0}, autosize=True,
scene=dict(
aspectmode='cube',
xaxis=dict(
title='X1'),
yaxis=dict(
title='X2'),
zaxis=dict(
title=r'f(x)'),
),
)
fig = go.Figure(fig)
fig.update_layout(layout, scene_camera=dict(eye=dict(x=1.25, y=1.25, z=1.25)))
fig.data = fig.data[0:2]
myPoly = jsonpickle.decode(ModelSet)
y_true = jsonpickle.decode(true_vals)
y_true = jsonpickle.decode(true_vals).ravel()
myPolyFit = myPoly.get_polyfit
DOE = myPoly.get_points()
N = 20
Expand All @@ -1169,16 +1162,19 @@ def Plot_poly_3D(ModelSet, n_clicks, true_vals, param_num,ndims,fig):
samples = np.hstack([S1_vec, S2_vec])
PolyDiscreet = myPolyFit(samples)
PolyDiscreet = np.reshape(PolyDiscreet, (N, N))

fig = go.Figure(fig)
fig.data = fig.data[0:2]
fig.plotly_restyle({'x': S1, 'y': S2, 'z': PolyDiscreet}, 0)
fig.plotly_restyle({'x': DOE[:, 0], 'y': DOE[:, 1], 'z': y_true.squeeze()}, 1)
fig.plotly_restyle({'x': DOE[:, 0], 'y': DOE[:, 1], 'z': y_true}, 1)
return fig,default
elif ndims==1:
layout = {"xaxis": {"title": r'X1'}, "yaxis": {"title": r'f(X)'},
'margin': {'t': 0, 'r': 0, 'l': 0, 'b': 60},
'paper_bgcolor': 'white', 'plot_bgcolor': 'white', 'autosize': True}

myPoly = jsonpickle.decode(ModelSet)
y_true = jsonpickle.decode(true_vals)
y_true = jsonpickle.decode(true_vals).ravel()
myPolyFit = myPoly.get_polyfit
DOE = myPoly.get_points()
N = 20
Expand All @@ -1192,12 +1188,16 @@ def Plot_poly_3D(ModelSet, n_clicks, true_vals, param_num,ndims,fig):
fig.update_xaxes(color='black', linecolor='black', showline=True, tickcolor='black', ticks='outside')
fig.update_yaxes(color='black', linecolor='black', showline=True, tickcolor='black', ticks='outside')
fig.update_layout(layout)
if len(fig.data)==3:
fig.plotly_restyle({'x':DOE[:,0],'y':y_true.flatten()},2)

fig.plotly_restyle({'x': [[]], 'y': [[]], 'z': [[]]}, 0)
fig.plotly_restyle({'x': [[]], 'y': [[]], 'z': [[]]}, 1)
if len(fig.data) == 4:
fig.plotly_restyle({'x': DOE[:,0], 'y': y_true}, 2)
fig.plotly_restyle({'x': S1 , 'y': PolyDiscreet}, 3)
else:
fig.add_trace(go.Scatter(x=DOE[:, 0], y=y_true.flatten(), mode='markers', name='Training samples',
marker=dict(color='rgb(135,206,250)', size=15, opacity=0.5,
line=dict(color='rgb(0,0,0)', width=1))))
fig.add_trace(go.Scatter(x=DOE[:,0], y=y_true, mode='markers', name='Training samples',
marker=dict(color='rgb(135,206,250)', size=15, opacity=0.5,
line=dict(color='rgb(0,0,0)', width=1))))
fig.add_trace(go.Scatter(x=S1,y=PolyDiscreet,mode='lines',name='f(x)',line_color='rgb(178,34,34)'))

return fig,default
Expand Down

0 comments on commit 1b7520a

Please sign in to comment.