Based of the plot shown in the last post of this topic : (here for Y-axis) I tried to change the script in order to obtain the same things but for the bottom of X axis. I modified the script in this way but: 1) the red Axis is present on the top as well 2) the 2 external axis have not the ticks
the code is this:
import matplotlib.pyplot as plt
import numpy as np
# To make things reproducible...
#np.random.seed(1977)
#plt.style.use(['mystyle'])
fig, ax = plt.subplots()
# Twin the x-axis twice to make independent y-axes.
axes = [ax, ax.twiny(), ax.twiny()]
# Make some space on the right side for the extra y-axis.
fig.subplots_adjust(bottom=0.5)
# Move the last y-axis spine over to the right by 20% of the width of the axes
axes[1].spines['bottom'].set_position(('axes', -0.25))
axes[2].spines['bottom'].set_position(('axes', -0.5))
# To make the border of the right-most axis visible, we need to turn the frame
# on. This hides the other plots, however, so we need to turn its fill off.
axes[-1].set_frame_on(True)
axes[-1].patch.set_visible(False)
# And finally we get to plot things...
colors = ('Green', 'Red', 'Blue')
intAxNo = 0
x = [[0],[0],[0],[0]]
i=0
for ax, color in zip(axes, colors):
intAxNo += 1
i +=1
print(i)
#data = np.random.random(1) * np.random.random(10)
x[i]=np.linspace(0.,4*i,100)
ax.plot(x[i], np.sin(i*x[i]) , linestyle='-', color=color)
if (intAxNo > 1):
if (intAxNo == 2):
ax.set_xlabel('%s Thing' % color, color=color, labelpad = -255 )
ax.tick_params(axis='x', colors=color, labelbottom=True)
elif (intAxNo == 3):
ax.set_xlabel('%s Thing' % color, color=color, labelpad = -295 )
ax.tick_params(axis='x', colors=color, labelbottom=True)
ax.get_xaxis().set_tick_params(direction='out',length=6, width=2, colors='r')
else:
ax.set_xlabel('%s Thing' % color, color=color, labelpad = +0 )
ax.tick_params(axis='x', colors=color, labelbottom=True)
axes[0].set_ylabel('Y-axis')
plt.show()
and I obtain this , may somebody help me explain what I wrong ? and what I should do