Commit e563d12d authored by mathpluscode's avatar mathpluscode

fix analyse plot

parent dd82f8d7
......@@ -86,11 +86,11 @@ def analyse_foreground(log_path, best, std):
print('metric %s not found' % metric_name)
continue
fig = make_subplots(rows=1, cols=1)
for name in names:
for i, name in enumerate(names):
metrics = metrics_total[name]
props = metrics['prop']
vals = metrics[metric_name]
fig = plot_prop_val(props, vals, std, fig, name)
fig = plot_prop_val(props, vals, std, fig, i, name)
fig.layout.update(autosize=False,
width=800,
......@@ -124,13 +124,13 @@ def analyse_foreground_all(log_path, best, std):
continue
fig = make_subplots(rows=1, cols=1)
for mode in ['test', 'train']:
for name in names:
for i, name in enumerate(names):
metrics = metrics_sep[name]
props = metrics['prop']['test']
vals = metrics[metric_name][mode]
if mode == 'train':
vals = np.mean(vals, axis=0)
fig = plot_prop_val(props, vals, std, fig, name + '-' + mode)
fig = plot_prop_val(props, vals, std, fig, i, name + '-' + mode)
fig.layout.update(autosize=False,
width=800,
......@@ -140,7 +140,7 @@ def analyse_foreground_all(log_path, best, std):
pio.write_image(fig, '%s_vs_prop_train_test.pdf' % metric_name)
def plot_prop_val(props, vals, std, fig, name, num_bins=30):
def plot_prop_val(props, vals, std, fig, fig_id, name, num_bins=30):
"""
plot the foreground proportion vs performance curve
:param props:
......@@ -165,11 +165,12 @@ def plot_prop_val(props, vals, std, fig, name, num_bins=30):
prop_mean = np.asarray(prop_mean)
val_mean = np.asarray(val_mean)
val_std = np.asarray(val_std)
fig.append_trace(
fig.add_trace(
go.Scatter(x=prop_mean,
y=val_mean,
mode='lines+markers',
marker=dict(color=DEFAULT_PLOTLY_COLORS[i % 10]),
marker=dict(color=DEFAULT_PLOTLY_COLORS[fig_id % 10]),
showlegend=False,
name=name,
),
......@@ -181,19 +182,19 @@ def plot_prop_val(props, vals, std, fig, name, num_bins=30):
fill=None,
mode='lines',
line_color=rgb2rgba(
DEFAULT_PLOTLY_COLORS[col - 1], 0.4),
DEFAULT_PLOTLY_COLORS[fig_id % 10], 0.4),
showlegend=False,
name='mean-std'),
row=row, col=col)
fig.add_trace(
go.Scatter(x=prop_mean,
y=val_mean + val_std,
fill='tonexty',
mode='lines',
line_color=rgb2rgba(
DEFAULT_PLOTLY_COLORS[col - 1], 0.4),
showlegend=False, name='mean+std'),
row=row, col=col)
fig.add_trace(
go.Scatter(x=prop_mean,
y=val_mean + val_std,
fill='tonexty',
mode='lines',
line_color=rgb2rgba(
DEFAULT_PLOTLY_COLORS[fig_id % 10], 0.4),
showlegend=False, name='mean+std'),
row=row, col=col)
fig.update_xaxes(range=[0, 1],
title=dict(text='Liver Proportion'),
row=row, col=col)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment