Skip to content

Commit

Permalink
added dashed red diagonal on scatterplot (#63)
Browse files Browse the repository at this point in the history
* added dashed red diagonal and use of empty dots in scatterplot

* formatting fixed

Co-authored-by: Massimiliano Lupo Pasini <7ml@ornl.gov>
  • Loading branch information
allaffa and Massimiliano Lupo Pasini authored Dec 17, 2021
1 parent 63ccf39 commit 2d391e0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion hydragnn/postprocess/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def __scatter_impl(
y_label=None,
xylim_equal=False,
):
ax.scatter(x, y, s, c, marker)
ax.scatter(x, y, s=s, edgecolor="b", marker=marker, facecolor="none")

ax.set_title(title)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
Expand All @@ -124,6 +125,8 @@ def __scatter_impl(
ax.set_xlim(minimum, maximum)
ax.set_ylim(minimum, maximum)

self.add_identity(ax, color="r", ls="--")

def create_plot_global_analysis(
self, varname, true_values, predicted_values, save_plot=True
):
Expand Down Expand Up @@ -550,6 +553,21 @@ def create_scatter_plot_nodes_vec(
fig.savefig(f"./logs/{self.model_with_config_name}/" + varname + ".png")
plt.close()

def add_identity(self, axes, *line_args, **line_kwargs):
(identity,) = axes.plot([], [], *line_args, **line_kwargs)

def callback(axes):
low_x, high_x = axes.get_xlim()
low_y, high_y = axes.get_ylim()
low = max(low_x, low_y)
high = min(high_x, high_y)
identity.set_data([low, high], [low, high])

callback(axes)
axes.callbacks.connect("xlim_changed", callback)
axes.callbacks.connect("ylim_changed", callback)
return axes

def plot_history(
self,
total_loss_train,
Expand Down

0 comments on commit 2d391e0

Please sign in to comment.