I\'m trying to add a second x axis to the top of a plot using twiny.
If I make a simple scatter plot with no colorbar, the top x axis is correctly aligned with the botto
This feels like kind of a hack. But by forcing the figure to draw. And then getting the ax1 position. you can set ax2 to the same and redraw the figure.
.... cbar.ax.tick_params(labelsize=10) fig.canvas.draw() ax2.set_position(ax1.get_position()) plt.show()