Skip to content

Commit

Permalink
Update NCL_xy_16.py to use the "reverse" option for the legend rather…
Browse files Browse the repository at this point in the history
… than a workaround
  • Loading branch information
kafitzgerald authored Oct 16, 2024
1 parent 63ba2c6 commit 0f9081e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Gallery/XY/NCL_xy_16.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@

# Add legend
handles, labels = ax.get_legend_handles_labels()
# Default order is the order in which the data was plotted
handles = reversed(handles) # Reverse order of legend elements
labels = reversed(labels)

plt.legend(handles,
labels,
loc='center right',
frameon=False,
fontsize=14,
labelspacing=1)
labelspacing=1,
reverse=True)

plt.show()

Expand Down Expand Up @@ -183,13 +182,13 @@
# Add legend
handles, labels = ax.get_legend_handles_labels()
# Default order is the order in which the data was plotted
handles = reversed(handles) # Reverse order of legend elements
labels = reversed(labels)

plt.legend(handles,
labels,
loc='center right',
frameon=False,
fontsize=14,
labelspacing=1)
labelspacing=1,
reverse=True)

plt.show()

0 comments on commit 0f9081e

Please sign in to comment.