Hello SciPy list; For my thesis I have an image which is also a spectrum of an object. I want to plot the image using imshow along with a data plot of the intensity, as can be seen on http://yfrog.com/0tforscipylistp . My questions are 2: 1) imshow() sets the ticks on the two upper subplots as pixels coordinates. What I want to show as tick labels on my x-axis is the wavelength coordinates of the lower plot on the upper images (since there is a straightforward pixel-to-wavelength conversion). I have googled everywhere but can't seem to find a solution, is it possible? 2) Is there any possible way to make the subplots layout look a bit nicer? Ideally to squeeze the two upper plots closer together and stretch the lower plot vertically, or at least to make the two upper subplots take up an equal amount of space? Best regards; Emil, python-newb and (former) IDL-user, Master student of Astrophysics at the University of Copenhagen, Niels Bohr Instutute.
2010/5/28 Thøger Emil Juul Thorsen <thoeger@fys.ku.dk>:
Hello SciPy list;
The matplotlib list is over here: https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Hello, You may wish to check out pcolor() and/or pcolormesh() as they allow you to specify the coordinate system. As for how to space the plots better, there are some options. The one trick that I know of is to specify that you are using 3 rows when plotting the first two subplots, but then say that you are using 2 rows when plotting the last plot (or something like that). There is also AxesGrid, but I haven't tried using it to do what you are thinking. Ben Root 2010/5/28 Thøger Emil Juul Thorsen <thoeger@fys.ku.dk>
Hello SciPy list;
For my thesis I have an image which is also a spectrum of an object. I want to plot the image using imshow along with a data plot of the intensity, as can be seen on http://yfrog.com/0tforscipylistp .
My questions are 2:
1) imshow() sets the ticks on the two upper subplots as pixels coordinates. What I want to show as tick labels on my x-axis is the wavelength coordinates of the lower plot on the upper images (since there is a straightforward pixel-to-wavelength conversion). I have googled everywhere but can't seem to find a solution, is it possible?
2) Is there any possible way to make the subplots layout look a bit nicer? Ideally to squeeze the two upper plots closer together and stretch the lower plot vertically, or at least to make the two upper subplots take up an equal amount of space?
Best regards;
Emil, python-newb and (former) IDL-user, Master student of Astrophysics at the University of Copenhagen, Niels Bohr Instutute.
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On May 28, 2010, at 9:29 AM, Thøger Emil Juul Thorsen wrote:
Hello SciPy list;
For my thesis I have an image which is also a spectrum of an object. I want to plot the image using imshow along with a data plot of the intensity, as can be seen on http://yfrog.com/0tforscipylistp .
My questions are 2:
1) imshow() sets the ticks on the two upper subplots as pixels coordinates. What I want to show as tick labels on my x-axis is the wavelength coordinates of the lower plot on the upper images (since there is a straightforward pixel-to-wavelength conversion). I have googled everywhere but can't seem to find a solution, is it possible?
2) Is there any possible way to make the subplots layout look a bit nicer? Ideally to squeeze the two upper plots closer together and stretch the lower plot vertically, or at least to make the two upper subplots take up an equal amount of space?
Best regards;
Emil, python-newb and (former) IDL-user, Master student of Astrophysics at the University of Copenhagen, Niels Bohr Instutute.
Hey Emil, 1) You should try the `extent` argument in `imshow`. From the docs for imshow: *extent*: [ None | scalars (left, right, bottom, top) ] Data limits for the axes. The default assigns zero-based row, column indices to the *x*, *y* centers of the pixels. For example:
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2*np.pi) Y = np.sin([x, x]) plt.imshow(Y, extent=[0, 2*np.pi, 0, 1])
2) If you're plotting interactively, you can configure the subplots using the command on the toolbar (3rd from right). If you want to add the adjustment to your script use `subplots_adjust`. For example,
plt.subplots_adjust(hspace=0.1)
where "hspace" is the spacing (height) between subplots. Of course, change the value of hspace to suit your needs. I'm actually surprised there's so much spacing between your subplots, so I suspect you may be doing something strange in your plot script. If subplots_adjust doesn't work it may be helpful to see your plot script, BUT.... Please move this discussion to the matplotlib-users list (https://lists.sourceforge.net/lists/listinfo/matplotlib-users), if you have further questions or want to follow-up on this question. It's more appropriate for matplotlib-specific questions. Best, -Tony
participants (4)
-
Benjamin Root -
Robert Kern -
Thøger Emil Juul Thorsen -
Tony S Yu