Example #1
0
def get_labels(x: unyt.unyt_array, y: unyt.unyt_array,
               mass_function: bool) -> None:
    """
    Set the x and y labels for the axes.
    """

    x_label = tools.get_full_label(x)
    y_label = (tools.get_mass_function_label(mass_function_sub_label="{}",
                                             mass_function_units=y.units)
               if mass_function else tools.get_full_label(y))

    return x_label, y_label
Example #2
0
# Create background scatter plot of galaxy size data
ax.scatter(stellar_masses, stellar_ages, s=1, edgecolor="none")

# Only plot median line for values that are reasonable
selection = stellar_ages > 0 * unyt.Gyr
ax.errorbar(
    *tools.binned_median_line(
        stellar_masses[selection], stellar_ages[selection], stellar_mass_bins
    )
)

# Setting nice limits on the plot...
ax.set_xlim(stellar_mass_bins[0], stellar_mass_bins[-1])
ax.set_ylim(5 * unyt.Gyr, 15 * unyt.Gyr)

# Add redshift and scale factor for easy plot identification
ax.text(
    0.95,
    0.05,
    f"$z={data.z:2.3f}$\n$a={data.a:2.3f}$",
    ha="right",
    va="bottom",
    transform=ax.transAxes,
)

ax.set_xlabel(tools.get_full_label(stellar_masses))
ax.set_ylabel(tools.get_full_label(stellar_ages))

fig.savefig("stellar_ages.pdf")
Example #3
0
fig, ax = plt.subplots(constrained_layout=True)
ax.loglog()

# create_mass_function creates a mass function in the expected way,
# i.e. using equal width bins of log(a)
bin_centers, mass_function, error = tools.create_mass_function(
    halo_masses, lowest_halo_mass, highest_halo_mass, box_volume
)

ax.errorbar(bin_centers, mass_function, error)

ax.set_xlim(lowest_halo_mass, highest_halo_mass)
ax.set_ylim(lowest_mf, highest_mf)

# Add redshift and scale factor for easy plot identification
ax.text(
    0.95,
    0.95,
    f"$z={data.z:2.3f}$\n$a={data.a:2.3f}$",
    ha="right",
    va="top",
    transform=ax.transAxes,
)

ax.set_xlabel(tools.get_full_label(halo_masses))
# This nice function allows for you to get a good label for your SMF for free!
ax.set_ylabel(tools.get_mass_function_label("H", mass_function.units))

fig.savefig("halo_mass_function.pdf")
Example #4
0
# Create background scatter plot of galaxy size data
ax.scatter(stellar_masses, galaxy_sizes, s=1, edgecolor="none")

# Only plot median line for values that are reasonable
selection = galaxy_sizes > 1e-1 * unyt.kpc
ax.errorbar(
    *tools.binned_median_line(
        stellar_masses[selection], galaxy_sizes[selection], stellar_mass_bins
    )
)

# Setting nice limits on the plot...
ax.set_xlim(stellar_mass_bins[0], stellar_mass_bins[-1])
ax.set_ylim(1e0 * unyt.kpc, 1e1 * unyt.kpc)

# Add redshift and scale factor for easy plot identification
ax.text(
    0.95,
    0.05,
    f"$z={data.z:2.3f}$\n$a={data.a:2.3f}$",
    ha="right",
    va="bottom",
    transform=ax.transAxes,
)

ax.set_xlabel(tools.get_full_label(stellar_masses))
ax.set_ylabel(tools.get_full_label(galaxy_sizes))

fig.savefig("galaxy_sizes.pdf")