【问题标题】:Issue with plots in SpyderSpyder 中的绘图问题
【发布时间】:2021-04-18 13:31:31
【问题描述】:

当我使用 plt.plot(x,y) 时,默认情况下我会在 Spyders 绘图显示中得到以下内容:

但是,我想要:

黑色轴线和白色背景。如何设置?

ax4.axes.get_xaxis().set_visible(True) 
ax4.spines['bottom'].set_color('black')
ax4.tick_params(axis='x', colors='black')
ax4.tick_params(axis='y', colors='black')

没用。

获取默认值的代码:

fig = plt.figure(figsize=(8.5,11)) 
ax4 = fig.add_subplot(3,1,2)

Dist25 = np.load('Dist25.npy')

Dist100 = np.load('Dist100.npy') 


r =1 
#
ax4.plot(Dist25[0::r,3],Dist25[0::r,0],'or', color = 'xkcd:azure')
ax4.plot(Dist100[0::r,3],Dist100[0::r,0],'<r', color = 'xkcd:chartreuse')
 


ax4.set_xscale('log')


ax4.set_ylim((1.5,2.5))


ax4.fill_between(Dist25[0::r,3], Dist25[0::r,0] - Dist25[0::r,1], Dist25[0::r,0] + Dist25[0::r,1],
                 color='xkcd:azure', alpha=0.2)




ax4.fill_between(Dist100[0::r,3], Dist100[0::r,0] - Dist100[0::r,1], Dist100[0::r,0] + Dist100[0::r,1],
                 color='xkcd:chartreuse', alpha=0.2)




for tick in ax4.xaxis.get_majorticklabels():  # example for xaxis
    tick.set_fontsize(18)

for tick in ax4.yaxis.get_majorticklabels():  # example for xaxis
    tick.set_fontsize(18)

ax4.set_title('B) Distance from chain', fontsize = 25) 
ax4.set_xlabel('Simulation time (ps)', fontsize = 20) 
ax4.set_ylabel('Distance (nm)', fontsize = 20)

【问题讨论】:

  • 请包含您用于创建绘图的代码。
  • 不确定,因为在 oython idle 例如使用 matplotlib 时不会出现此问题。
  • 重启内核后问题是否依然存在?
  • 你是怎么做到的?重启spyder?是的,它仍然存在
  • Ctrl+. 应该重启内核:i.stack.imgur.com/zzrSJ.png

标签: python matplotlib spyder


【解决方案1】:

我通过添加解决了这个问题: plt.style.use('经典') 到我的代码:)

【讨论】:

    猜你喜欢
    • 2014-07-23
    • 2017-08-19
    • 2016-05-19
    • 2020-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-24
    • 1970-01-01
    相关资源
    最近更新 更多