From 40ce8ec1c894e3bbfcd7f63343fc1367589ab9fd Mon Sep 17 00:00:00 2001 From: jayaprajapatii Date: Mon, 25 May 2026 14:21:54 +0000 Subject: [PATCH] Consolidate top and right ticks example --- galleries/examples/ticks/ticks_top_right.py | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 galleries/examples/ticks/ticks_top_right.py diff --git a/galleries/examples/ticks/ticks_top_right.py b/galleries/examples/ticks/ticks_top_right.py new file mode 100644 index 000000000000..e035aea77250 --- /dev/null +++ b/galleries/examples/ticks/ticks_top_right.py @@ -0,0 +1,35 @@ +""" +================================= +Ticks and labels on top and right +================================= + +Demonstrate moving ticks, tick labels, and axis labels +to the top or right side of an Axes. + +""" + +import matplotlib.pyplot as plt + +fig, ax = plt.subplots() +ax.plot(range(10)) + +# Move ticks and tick labels to the top and right +ax.tick_params( + top=True, + labeltop=True, + bottom=False, + labelbottom=False, + right=True, + labelright=True, + left=False, + labelleft=False, +) + +# Move axis labels +ax.xaxis.set_label_position("top") +ax.yaxis.set_label_position("right") + +ax.set_xlabel("X label") +ax.set_ylabel("Y label") + +plt.show()