Multipanel with PhasePlot

Dear YT user, I'm trying to draw a multipanel Phaseplot in yt. There is no problem with drawing the plot, but the problem is the size of figure. As shown in my figure (https://drive.google.com/file/d/1IM_slIts1lgtQ95m-sKHf7EncIM2ZvoO/view?usp=d...) or yt document here (https://yt-project.org/doc/cookbook/complex_plots.html#multipanel-with-phase...), the images are compressed, not the square shape. I tried fig = plt.figure(figsize = (2,8)) but it doesn't work and the set_figure_size function is only for the size of the figure on the longest axis. I've searched the YT document, it seems that there is no function that adjusts the width or height of the figure. Each image comes out as a square if I draw the multipanel with Projectionplot, it doesn't work with Phaseplot. Is there any way to handle the size of the figures or axesgrid in YT? Thanks in advance. Hyeonyong

Hi there, The best (in my opinion) way of solving this problem is by going around it and using create_profile function. I really like this method because it offers great customisability Here is a snippet of my code that illustrates this: fig, ax = plt.subplots(2, 3, figsize=(8, 5), sharex='all', sharey='all') for i in range(2): for j in range(3): ad = ds.all_data() #here I normally go over selecting the required data bins_dense = np.logspace(-29, -21, num=80) bins_vz = np.linspace(-1000, 1000, num=80) logs = dict(velocity_cylindrical_z=False, density=True) units = dict(velocity_cylindrical_z='km/s') profile = yt.create_profile(gal_dense, ['density', 'velocity_cylindrical_z'], fields='cell_mass', weight_field=None, units=units, logs=logs, override_bins={'density': bins_dense, 'velocity_cylindrical_z': bins_vz}) prof = profile['cell_mass'] im = ax[i, j].pcolormesh(profile.x, profile.y, prof.d.T, cmap='arbre', norm = matplotlib.colors.LogNorm(vmin=1e0, vmax=1e4)) ax[i, j].set_xscale('log') ax[i, j].set_xlim(1e-29, 1e-21) ax[i, j].set_ylim(-1000, 1000) # and so on Here I want to plot density on x-axis and velocity_cylindrical_z on y-axis, colour-coded by cell_mass You can select whether you want axes to be log or linear, bin size and limits and the units (used in the bins) Then you select the data in prof = profile['cell_mass’] and just plot it using regular subplots so you can set aspect playing with figsize or ax[i].set_aspect('equal’) or fig.subplots_adjust() Hope it helps! I use this method extensively so don’t hesitate to contact me if you have any questions :) Nina
On 25 Jul 2024, at 13:27, HyeonYong Kim <gusdyd398@snu.ac.kr> wrote:
Dear YT user,
I'm trying to draw a multipanel Phaseplot in yt. There is no problem with drawing the plot, but the problem is the size of figure.
As shown in my figure (https://drive.google.com/file/d/1IM_slIts1lgtQ95m-sKHf7EncIM2ZvoO/view?usp=d...) or yt document here (https://yt-project.org/doc/cookbook/complex_plots.html#multipanel-with-phase...), the images are compressed, not the square shape.
I tried fig = plt.figure(figsize = (2,8)) but it doesn't work and the set_figure_size function is only for the size of the figure on the longest axis. I've searched the YT document, it seems that there is no function that adjusts the width or height of the figure.
Each image comes out as a square if I draw the multipanel with Projectionplot, it doesn't work with Phaseplot. Is there any way to handle the size of the figures or axesgrid in YT?
Thanks in advance. Hyeonyong _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: akermannia@gmail.com

Hi Nina, I apologize for the delayed response. I thought I had replied to you earlier. Regarding the matter at hand, the create_profile function works very well! As you mentioned, it provides great customizability. While I hope the Phaseplot function will support Multipanel plots in the future, the create_profile function is a useful and very good alternative. Thanks! Hyeonyong

Dear YT users, I found that this can be solved by adding "grid[i].set_aspect(ratio you want)" in the yt document script. While this method is straightforward, Nina's solution might offer more flexibility for further customization. Best regards, Hyeonyong
participants (2)
-
HyeonYong Kim
-
Nina Akerman