相关疑难解决方法(0)

Matplotlib因此log轴仅在指定点处具有次要刻度标记.还可以更改颜色栏中刻度标签的大小

我正在尝试创建一个图,但我只想让ticklabels显示如上所示的对数比例.我只希望显示50,500和2000的次要标签.无论如何指定要显示的次要刻度标签?我一直试图解决这个问题,但没有找到一个好的解决方案.我能想到的就是获取minorticklabels()并将fontsize设置为0.这显示在第一段代码下面.我希望有一个更清洁的解决方案.

另一件事是改变颜色栏中的勾选标签的大小,我还没想到.如果有人知道这样做的方法,请告诉我,因为我没有看到颜色栏中的方法很容易做到这一点.

第一个代码:

fig = figure(figto)
ax = fig.add_subplot(111)
actShape = activationTrace.shape
semitones = arange(actShape[1])
freqArray = arange(actShape[0])
X,Y = meshgrid(self.testFreqArray,self.testFreqArray)
Z = sum(activationTrace[:,:,beg:end],axis=2)
surf = ax.contourf(X,Y,Z, 8, cmap=cm.jet)
ax.set_position([0.12,0.15,.8,.8])
ax.set_ylabel('Log Frequency (Hz)')
ax.set_xlabel('Log Frequency (Hz)')
ax.set_xscale('log')
ax.set_yscale('log')
ax.xaxis.set_minor_formatter(FormatStrFormatter('%d'))
ax.yaxis.set_ticks_position('left')
ax.xaxis.set_ticks_position('bottom')
ax.tick_params(axis='both',reset=False,which='both',length=8,width=2)
self.plotSetAxisLabels(ax,22)
self.plotSetAxisTickLabels(ax,18)
cbar = fig.colorbar(surf, shrink=0.5, aspect=20, fraction=.12,pad=.02)
cbar.set_label('Activation',size=18)
return ax, cbar
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

第二代码:

fig = figure(figto)
ax = fig.add_subplot(111)
actShape = activationTrace.shape
semitones = arange(actShape[1])
freqArray = arange(actShape[0])
X,Y = meshgrid(self.testFreqArray,self.testFreqArray)
Z = sum(activationTrace[:,:,beg:end],axis=2)
surf = ax.contourf(X,Y,Z, 8, …
Run Code Online (Sandbox Code Playgroud)

python numpy matplotlib scipy

18
推荐指数
1
解决办法
2万
查看次数

标签 统计

matplotlib ×1

numpy ×1

python ×1

scipy ×1