How to plot with the x axis at the top of the picture?

I would like to ask how to create a plot similar to the one shown in the image below? Basically, how to have the x axis at the top of the picture. Thanks

enter image description here

Image from: http://oceanographyclay1987.blogspot.com/2010/10/light-attenuation-in-ocean.html

+7
source share
1 answer

Using

ax.xaxis.set_ticks_position("top") 

For example,

 import numpy as np import matplotlib.pyplot as plt numdata = 100 t = np.linspace(0, 100, numdata) y = 1/t**(1/2.0) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.xaxis.set_ticks_position('top') ax.yaxis.grid(linestyle = '-', color = 'gray') ax.invert_yaxis() ax.plot(t, y, 'g-', linewidth = 1.5) plt.show() 

enter image description here

+9
source

All Articles