matplotlib子地块未显示

2024-09-26 22:50:23 发布

您现在位置:Python中文网/ 问答频道 /正文

右边的柱状图没有显示,知道发生了什么吗??我可以将它们堆叠在一起,但当我尝试制作两列时,右边的列不会出现。此外,当我尝试使用%matplotlib笔记本时,该图形完全消失。我已经包括了我的身材的屏幕截图

%matplotlib inline

# RING 1 PLOTS

fig, axs = plt.subplots(6, 2)
fig = plt.figure(figsize=(20,20))

axs[0,0].plot(t, ring.IN_1.soma_v, color='black', label='IN soma')
axs[0,0].plot(t, ring.IN_1.dend_prox_v, color='grey', label='IN prox dend')
axs[0,0].plot(t, ring.IN_1.dend_dist_v, color='red', label='IN dist dend')
axs[0,0].plot(t, ring.IN_1.dend_dist2_v, color='blue', label='IN dist2 dend')
axs[0,0].legend(loc='upper right', frameon=False)
axs[0,0].set_ylabel('mV')
axs[0,0].set_xticks([])
axs[0,0].set_xlim([50,300])
axs[0,0].set_ylim([-100,50])

axs[1,0].plot(t, ring.TCcells[0].soma_v, color='black', label='TC1 soma')
axs[1,0].plot(t, ring.TCcells[0].dend_prox_v, color= 'grey', label='TC1 dend')
axs[1,0].legend(frameon = False)
axs[1,0].set_ylabel('mV')
axs[1,0].set_xticks([])
axs[1,0].set_xlim([50,300])
axs[1,0].set_ylim([-100,50])

axs[2,0].plot(t, ring.TCcells[1].soma_v, color='black', label='TC2 soma')
axs[2,0].plot(t, ring.TCcells[1].dend_prox_v, color= 'grey', label='TC2 dend')
axs[2,0].legend(frameon = False)
axs[2,0].set_ylabel('mV')
axs[2,0].set_xticks([])
axs[2,0].set_xlim([50,300])
axs[2,0].set_ylim([-100,50])

axs[3,0].plot(t, ring.TCcells[2].soma_v, color='black', label='TC3 soma')
axs[3,0].plot(t, ring.TCcells[2].dend_prox_v, color= 'grey', label='TC3 dend')
axs[3,0].legend(frameon = False)
axs[3,0].set_ylabel('mV')
axs[3,0].set_xticks([])
axs[3,0].set_xlim([50,300])
axs[3,0].set_ylim([-100,50])

axs[4,0].plot(t, ring.TCcells[3].soma_v, color='black', label='TC4 soma')
axs[4,0].plot(t, ring.TCcells[3].dend_prox_v, color= 'grey', label='TC4 dend')
axs[4,0].legend(frameon = False)
axs[4,0].set_ylabel('mV')
axs[4,0].set_xticks([])
axs[4,0].set_xlim([50,300])
axs[4,0].set_ylim([-100,50])

axs[5,0].plot(t, ring.TCcells[4].soma_v, color='black', label='TC5 soma')
axs[5,0].plot(t, ring.TCcells[4].dend_prox_v, color= 'grey', label='TC5 dend')
axs[5,0].legend(frameon = False)
axs[5,0].set_ylabel('mV')
axs[5,0].set_xlabel('time (ms)')
axs[5,0].set_xlim([50,300])
axs[5,0].set_ylim([-100,50])
plt.show()

# RING 2 PLOTS
axs[0,1].plot(t, ring2.IN_1.soma_v, color='black', label='IN soma')
axs[0,1].plot(t, ring2.IN_1.dend_prox_v, color='grey', label='IN prox dend')
axs[0,1].plot(t, ring2.IN_1.dend_dist_v, color='red', label='IN dist dend')
axs[0,1].plot(t, ring2.IN_1.dend_dist2_v, color='blue', label='IN dist2 dend')
axs[0,1].legend(loc='upper right', frameon = False)
axs[0,1].set_ylabel('mV')
axs[0,1].set_xticks([]) # Use ax2's tick labels
axs[0,1].set_xlim([50,300])
axs[0,1].set_ylim([-100,50])

axs[1,1].plot(t, ring2.TCcells[0].soma_v, color='black', label='TC1 soma')
axs[1,1].plot(t, ring2.TCcells[0].dend_prox_v, color= 'grey', label='TC1 dend')
axs[1,1].legend(frameon = False)
axs[1,1].set_ylabel('mV')
axs[1,1].set_xticks([])
axs[1,1].set_xlim([50,300])
axs[1,1].set_ylim([-100,50])

axs[2,1].plot(t, ring2.TCcells[1].soma_v, color='black', label='TC2 soma')
axs[2,1].plot(t, ring2.TCcells[1].dend_prox_v, color= 'grey', label='TC2 dend')
axs[2,1].legend(frameon = False)
axs[2,1].set_ylabel('mV')
axs[2,1].set_xticks([])
axs[2,1].set_xlim([50,300])
axs[2,1].set_ylim([-100,50])

axs[3,1].plot(t, ring2.TCcells[2].soma_v, color='black', label='TC3 soma')
axs[3,1].plot(t, ring2.TCcells[2].dend_prox_v, color= 'grey', label='TC3 dend')
axs[3,1].legend(frameon = False)
axs[3,1].set_ylabel('mV')
axs[3,1].set_xticks([])
axs[3,1].set_xlim([50,300])
axs[3,1].set_ylim([-100,50])

axs[4,1].plot(t, ring2.TCcells[3].soma_v, color='black', label='TC4 soma')
axs[4,1].plot(t, ring2.TCcells[3].dend_prox_v, color= 'grey', label='TC4 dend')
axs[4,1].legend(frameon = False)
axs[4,1].set_ylabel('mV')
axs[4,1].set_xticks([])
axs[4,1].set_xlim([50,300])
axs[4,1].set_ylim([-100,50])

axs[5,1].plot(t, ring2.TCcells[4].soma_v, color='black', label='TC5 soma')
axs[5,1].plot(t, ring2.TCcells[4].dend_prox_v, color= 'grey', label='TC5 dend')
axs[5,1].legend(frameon = False)
axs[5,1].set_ylabel('mV')
axs[5,1].set_xlabel('time (ms)')
axs[5,1].set_xlim([50,300])
axs[5,1].set_ylim([-100,50])
plt.show()

enter image description here


Tags: inplotproxlabelcolorgreyblacklegend
1条回答
网友
1楼 · 发布于 2024-09-26 22:50:23

您正在使用plt.show()两次。删除第一个plt.show(),在绘制完所有图形后只使用一次

axs[5,0].set_ylim([-100,50])
plt.show()    # <          Remove this one

# RING 2 PLOTS
axs[0,1].plot(t, ring2.IN_1.soma_v, color='black', label='IN soma')
.
.
.
axs[5,1].set_ylim([-100,50])
plt.show()    # <          Use only this one

也试着更换

fig, axs = plt.subplots(6, 2)
fig = plt.figure(figsize=(20,20))

fig, axs = plt.subplots(6, 2, figsize=(20,20))

相关问题 更多 >

    热门问题