【发布时间】:2021-05-21 20:30:29
【问题描述】:
我有两个 NumPy 数组 (2700,1000),用于将 5 秒的雷达数据绘制为通道 1 和通道 2。2700 (m) 是范围,每 200 个 x 数表示一秒。
但我想每 2 秒向 x 轴添加一次刻度。 power_ch1 和 power_ch2 我上面提到的两个不同的数组。
csfont = {'fontname':'Times New Roman'} # font applied as 'Times New Roman'
fig, ax = plt.subplots()
plt.subplot(211) # Channel 1 located
plt.imshow(power_ch1, cmap='viridis', # Channel 1 is plotted with [plt.imshow()], colormap is 'viridis'
interpolation='nearest',
aspect='auto') # 475 number is time(s) and 405 number is range(km)
plt.title(r'Reveiver Channel A',**csfont) # plot title is written and font has been set as 'Times New Roman'
plt.ylabel('RANGE (km)',**csfont) # Text('RANGE') has been printed on the y-axis
plt.xlabel('LOCAL TIME (hh:mm:ss)',**csfont) # Text('LOCAL TIME (hh:mm:ss)') has been printed on the x-axis
plt.xticks(x, array_clock) # ticks set on x-axis and 'array_clock' printed here
plt.yticks(y) # ticks set on y-axis
cbar = plt.colorbar() # colorbar located
cbar.set_label('POWER (dB)',**csfont) # 'POWER (dB)' text printed next to colorbar
plt.subplot(212) # Channel 2 located
plt.imshow(power_ch2, cmap='viridis', # Channel 2 is plotted with [plt.imshow()], colormap is 'viridis'
interpolation='nearest',
aspect='auto') # 475 number is time(s) and 405 number is range(km)
plt.title(r'Reveiver Channel B',**csfont) # plot title is written and font has been set as 'Times New Roman'
plt.ylabel('RANGE (km)',**csfont) # Text('RANGE') has been printed on the y-axis
plt.xlabel('LOCAL TIME (hh:mm:ss)',**csfont) # Text('LOCAL TIME (hh:mm:ss)') has been printed on the x-axis
plt.xticks(x, array_clock) # ticks set on x-axis and 'array_clock' printed here
plt.yticks(y) # ticks set on y-axis
cbar = plt.colorbar() # colorbar located
cbar.set_label('POWER (dB)',**csfont) # 'POWER (dB)' text printed next to colorbar
fig.tight_layout() # tight_layout automatically adjusts subplot params so that the
# subplot(s) fits in to the figure area.
plt.show() # Display all open figures.
【问题讨论】:
标签: python numpy matplotlib time imshow