1

I made this plot: enter image description here

with the following code:

l = 0.6       
siz = 6
x = range (1,9)
plt.figure (1, figsize = (10,6))
plt.subplots_adjust( left  = 0.1,  right = 0.9,   bottom = 0.1,  top = 0.9     ,   wspace = 0.2,  hspace = 0.2)

plt.subplot(2,2,1)
plt.plot(x, grand_mean_RT_cumul_cues_TARGET_massed, "k", marker = "o", label  = "study 1", fillstyle = 'none', markersize=siz, linewidth = l)
plt.plot(x, grand_mean_RT_cumul_cues_DIST_massed, "k", marker = "o",     markersize=siz, linewidth = l)
plt.xlim(0,9)
plt.ylim(.4, .55)
plt.subplot(2,2,1).axes.set_xticklabels([])
plt.title("Massed practice", fontsize = 15)
plt.ylabel ('Mean RT (s)', fontsize = 15)
plt.yticks (np.arange (0.4, 0.56, 0.05))

ax = plt.subplot(2,2,1)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')

plt.subplot(2,2,3)
plt.plot(x, grand_accuracy_cumul_cues_TARGET_massed, "k", marker = "o", fillstyle = 'none', markersize=siz, linewidth = l, label ="Responses to targets" )
plt.plot(x, grand_accuracy_cumul_cues_DIST_massed, "k", marker = "o", markersize=siz, linewidth = l, label ="Responses to distractors")

plt.xlim(0,9)
plt.xticks (np.arange (1, 9, 1))
plt.ylim(0.95, 1.0)
plt.yticks (np.arange (0.9, 1.01, 0.05))
plt.ylabel ('Accuracy', fontsize = 15)
plt.xlabel ("Memory set repetition", fontsize = 15)

ax = plt.subplot(2,2,3)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')

plt.legend(loc = "lower center", prop={'size':11})

plt.subplot(2,2,2)
plt.plot(x, grand_mean_RT_cumul_cues_TARGET_spaced, "k", marker = "o",fillstyle = 'none',  markersize=siz, linewidth = l)
plt.plot(x, grand_mean_RT_cumul_cues_DIST_spaced, "k", marker = "o", markersize=siz, linewidth = l)
plt.xlim(0,9)
plt.ylim(.4, .55)
plt.xticks (np.arange (1, 9, 1))
plt.yticks (np.arange (0.4, 0.56, 0.05))
plt.title("Spaced practice", fontsize = 15)
plt.subplot(2,2,2).axes.set_xticklabels([])
plt.subplot(2,2,2).axes.set_yticklabels([])

ax = plt.subplot(2,2,2)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')


plt.subplot(2,2,4)
plt.plot(x, grand_accuracy_cumul_cues_TARGET_spaced, "k", marker = "o",  fillstyle = 'none', markersize=siz, linewidth = l, label ="Responses to targets" )
plt.plot(x,  grand_accuracy_cumul_cues_DIST_spaced, "k", marker = "o", markersize=siz, linewidth = l, label ="Responses to distractors")
plt.xlim(0,9)
plt.xticks (np.arange (1, 9, 1))
plt.subplot(2,2,4).axes.set_yticklabels([])
plt.xlim(0,9)
plt.ylim(0.95, 1.0)
plt.yticks (np.arange (0.9, 1.01, 0.05))
plt.xlabel ("Memory set repetition", fontsize = 15)


ax = plt.subplot(2,2,4)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')

I now want to truncate my plot in a way similar to the following example: enter image description here

I can't find to do that in a SIMPLE way within matplotlib. Any help would be appreciated.

user1363251
  • 421
  • 1
  • 11
  • 24
  • You are looking for a broken axis. And matplotlib has [**an example**](http://matplotlib.org/examples/pylab_examples/broken_axis.html) of how to do it. – ImportanceOfBeingErnest Mar 30 '17 at 23:02
  • 2
    Possible duplicate of [Python/Matplotlib - Is there a way to make a discontinuous axis?](http://stackoverflow.com/questions/5656798/python-matplotlib-is-there-a-way-to-make-a-discontinuous-axis) – ImportanceOfBeingErnest Mar 30 '17 at 23:02

0 Answers0