提交 acdd0b9b 编辑于 作者: Mijian Xu's avatar Mijian Xu 😷
浏览文件

add map axis

上级 fde130ae
流水线 #742 已通过 ,包含阶段
in 2 minute 和 36 second
import numpy as np import numpy as np
from mgpro import expand # from mgpro import expand
# import expand import expand
from mgpro.proj import * # from mgpro.proj import *
# from proj import * from proj import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.colors as colors import matplotlib.colors as colors
from scipy.fftpack import fft2, fftshift, ifft2, ifftshift from scipy.fftpack import fft2, fftshift, ifft2, ifftshift
...@@ -17,6 +17,11 @@ def msg(): ...@@ -17,6 +17,11 @@ def msg():
''' '''
def tick2label(ticks, lim):
labels = ['{:.0f}'.format(tick) for tick in np.linspace(lim[0], lim[1], len(ticks))]
return labels
def cal_pos(max_len, len_x, len_y): def cal_pos(max_len, len_x, len_y):
if max_len > 1 or max_len < 0: if max_len > 1 or max_len < 0:
raise ValueError('Input arg of max_len must be in the range of 0 to 1') raise ValueError('Input arg of max_len must be in the range of 0 to 1')
...@@ -168,8 +173,13 @@ class mgmat(object): ...@@ -168,8 +173,13 @@ class mgmat(object):
real_width *= frac_w real_width *= frac_w
fig.clf() fig.clf()
ax_raw = fig.gca() ax_raw = fig.gca()
pcm = ax_raw.imshow(data, cmap='jet', extent=[self.x[0], self.x[-1], self.y[0], self.y[-1]]) divnorm = colors.DivergingNorm(vcenter=0)
# ax_raw.figure.canvas.draw() pcm = ax_raw.pcolor(data, cmap='jet', norm=divnorm)
xticklabels = tick2label(ax_raw.get_xticks(), [self.x[0], self.x[-1]])
yticklabels = tick2label(ax_raw.get_yticks(), [self.y[0], self.y[-1]])
ax_raw.set_xticklabels(xticklabels)
ax_raw.set_yticklabels(yticklabels)
plt.setp(ax_raw.get_xticklabels(), rotation=-45, ha="left")
cb = fig.colorbar(pcm, extend='both') cb = fig.colorbar(pcm, extend='both')
# ax_raw.set_position([.1, .125, real_width, real_height], which='original') # ax_raw.set_position([.1, .125, real_width, real_height], which='original')
# cb.ax.set_position([.8, .1, real_height/6.27, real_height]) # cb.ax.set_position([.8, .1, real_height/6.27, real_height])
......
...@@ -5,7 +5,7 @@ packages = find_packages() ...@@ -5,7 +5,7 @@ packages = find_packages()
with open("README.md", "r") as fh: with open("README.md", "r") as fh:
long_description = fh.read() long_description = fh.read()
VERSION = "0.1.6" VERSION = "0.1.7"
setup(name='mgpro', setup(name='mgpro',
version=VERSION, version=VERSION,
author='Mijian Xu', author='Mijian Xu',
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册