invert broken y axis of scatter graph

Viewed 8

I am trying to invert the y axis of a broken scatter graph and I am having problems doing this.

import matplotlib.pyplot as plt
import numpy as np

x = np.genfromtxt("Working-GibbsE-N2.dat")
y = np.genfromtxt("Working-GibbsE-H.dat")
z = np.genfromtxt("Limiting-Potential.dat")

fig, (ax1, ax2) = plt.subplots(2, 1)
fig.subplots_adjust(hspace=0.05)  # adjust space between axes
sc = ax1.scatter(x, y, c=[z])
sc= ax2.scatter(x, y, c=[z])

ax1.set_ylim(-35, -45)  # outliers only
ax2.set_ylim(-10, -22)  # most of the data

# hide the spines between ax and ax2
ax1.spines.bottom.set_visible(False)
ax2.spines.top.set_visible(False)
ax1.xaxis.tick_top()
ax1.tick_params(labeltop=False)  # don't put tick labels at the top
ax2.xaxis.tick_bottom()

d = .5  # proportion of vertical to horizontal extent of the slanted line
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=11,
              linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax1.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax2.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)
cbar_ax = fig.add_axes([0.95, 0.15, 0.025, 0.7]) #setting the colorbar
cbar = fig.colorbar(sc,cax=cbar_ax)
cbar.set_label("Limiting Potential / V")
fig.savefig('H-N2-Potential.png', bbox_inches='tight', pad_inches=0, dpi = 1800)
plt.close()
0 Answers
Related