Skip to content

Commit

Permalink
get axes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang committed Dec 15, 2023
1 parent b2e5783 commit 7106357
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dianna/visualization/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ def plot_tabular(
"""
if not num_features:
num_features = len(x)
fig = plt.figure()
fig, ax = plt.subplots()
abs_values = [abs(i) for i in x]
top_values = [x for _, x in sorted(zip(abs_values, x), reverse=True)][:num_features]
top_features = [x for _, x in sorted(zip(abs_values, y), reverse=True)][
:num_features
]

colors = ["r" if x >= 0 else "b" for x in top_values]
plt.barh(top_features, top_values, color=colors)
plt.xlabel(x_label)
plt.ylabel(y_label)
ax.barh(top_features, top_values, color=colors)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)

if show_plot:
plt.show()
Expand Down

0 comments on commit 7106357

Please sign in to comment.