python - 更改楔形图的大小
问题描述
我想用一些星系的赤经和红移做一个楔形图。当我对某个 RA 范围执行此操作时,我的所有数据点都在楔形图中间的一条细线上。所以很自然地,我把限制变小了,认为这会“放大”线上,但它只会返回一个更小的楔形图。有谁知道我可以如何更改限制但保持楔形图的大小?为了清楚起见,请参阅图片“具有广泛的限制范围”和“较小的限制范围”。
绘制楔形图
def setup_axes3(fig, rect):
"""
Sometimes, things like axis_direction need to be adjusted.
"""
# rotate a bit for better orientation
tr_rotate = Affine2D().translate(-105, 0)
# scale degree to radians
tr_scale = Affine2D().scale(np.pi/180., 1.)
tr = tr_rotate + tr_scale + PolarAxes.PolarTransform()
grid_locator1 = angle_helper.LocatorHMS(4)
tick_formatter1 = angle_helper.FormatterHMS()
grid_locator2 = MaxNLocator(3)
# Specify theta limits in degrees
ra0, ra1 = 180, 210
# Specify radial limits
cz0, cz1 = 0.0, 0.04
grid_helper = floating_axes.GridHelperCurveLinear(
tr, extremes=(ra0, ra1, cz0, cz1),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None)
ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)
# adjust axis
ax1.axis["left"].set_axis_direction("bottom")
ax1.axis["right"].set_axis_direction("top")
ax1.axis["bottom"].set_visible(False)
ax1.axis["top"].set_axis_direction("bottom")
ax1.axis["top"].toggle(ticklabels=True, label=True)
ax1.axis["top"].major_ticklabels.set_axis_direction("top")
ax1.axis["top"].label.set_axis_direction("top")
ax1.axis["left"].label.set_text(r"z")
ax1.axis["top"].label.set_text(r"Right Ascension")
# create a parasite axes whose transData in RA, cz
aux_ax = ax1.get_aux_axes(tr)
aux_ax.patch = ax1.patch # for aux_ax to have a clip path as in ax
ax1.patch.zorder = 0.9 # but this has a side effect that the patch is
# drawn twice, and possibly over some other
# artists. So, we decrease the z-order a bit to
# prevent this.
return ax1, aux_ax
fig = plt.figure(figsize=(8, 8))
ax3, aux_ax3 = setup_axes3(fig, 111)
aux_ax3.scatter(ra, z, s = 0.4)
plt.grid(True)
plt.show()
参考:
解决方案
推荐阅读
- optimization - 导入 PAO 问题(基于 Python 的对抗优化包)
- ubuntu - 如何在 Ubuntu 21.04 终端中调用 npx cypress open 或 npx cypress run?
- xamarin.forms - 以 Xamarin 形式缩放图像
- ruby-on-rails - Postgresql/rails - 加入不同的值或只为不同的值创建重复的行
- javascript - 如何使用 Barba.js 从单个页面进行多个页面转换
- javascript - 在 github repo 的 Packages 部分下显示 npm 包的链接
- mysql - MySQL连接三个表并显示空值
- node.js - 如何从nodejs中的CSVTOJSON中仅提取某些字段?
- mysql - 如何将此复杂查询转换为等效的 Django ORM
- sql - 从动态链接服务器存储过程返回值