从matplotlib方向错误的FITS文件绘制的图像 [英] Image plotted from a FITS file with matplotlib oriented incorrectly

查看:88
本文介绍了从matplotlib方向错误的FITS文件绘制的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于使用matplotlibimshow绘制拟合图像,我遇到了一些问题.看来我的图像在水平和垂直方向都被翻转了.我敢肯定,如果有人能指出正确的方向,那我就会忽略一些简单的事情.

I'm having a little issue with something regarding plotting a fits image using matplotlib's imshow. It seems that my image is flipped both horizontally and vertically. I'm sure there is something simple I am overlooking, if anyone could point me in the right direction that would be great.

这是我的图像的样子:

因此,我将图像加载为:

So, I'm loading my image as:

from astropy.io import fits
import matplotlib
import matplotlib.pyplot as pyplot
#Opening/reading in my fits file
hdulist = fits.open('.../myfits.fits')
#Accessing the image data and specifying the dimensions I wish to use
my_image = hdulist[0].data[0,0:,0:]
#Plotting the image
pyplot.imshow(image_SWIFT_uvm2_plot, cmap='gray', vmin=0, vmax=0.5)
pyplot.show()

这是我在绘图中的图像的样子(绘图比我包含的代码复杂一点,但是我给出的关键行希望是自给自足的代码):

This is what my image in the plot looks like (the plot is a little more complex than the code I have included, but I have given the critical lines as, hopefully, a self-sufficient code):

那些敏锐的眼睛应该看到图像水平和垂直翻转.

Those of you with keen eyes should see that the image has flipped both horizontally and vertically.

推荐答案

对于FITS文件,约定是原点位于图像的左下角,因此您需要使用origin='lower'(默认情况下Matplotlib使用origin='upper').

For FITS files the convention is that the origin is at the lower left hand corner of the image, so you need to use origin='lower' (by default Matplotlib uses origin='upper').

这篇关于从matplotlib方向错误的FITS文件绘制的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆