Colormaps

There are several colormaps available for yt. yt includes all of the matplotlib colormaps as well for nearly all functions. Individual visualization functions usually allow you to specify a colormap with the cmap flag.

In yt 3.3, we changed the default yt colormap from algae to arbre. This colormap was designed and voted on by the yt community and is designed to be easier for people with different color sensitivities as well as when printed in black and white. In 3.3, additional colormaps dusk, kelp and octarine were also added, following the same guidelines. For a deeper dive into colormaps, see the SciPy 2015 talk by Stéfan van der Walt and Nathaniel Smith about the new matplotlib colormap viridis at https://www.youtube.com/watch?v=xAoljeRJ3lU .

To specify a different default colormap (including viridis), in your yt configuration file (see The Configuration) you can set the value default_colormap to the name of the colormap you would like. In contrast to previous versions of yt, starting in 3.3 yt no longer overrides any matplotlib defaults and instead only applies the colormap to yt-produced plots.

Palettable and ColorBrewer2

While colormaps that employ a variety of colors often look attractive, they are not always the best choice to convey information to one’s audience. There are numerous articles and presentations that discuss how rainbow-based colormaps fail with regard to black-and-white reproductions, colorblind audience members, and confusing in color ordering. Depending on the application, the consensus seems to be that gradients between one or two colors are the best way for the audience to extract information from one’s figures. Many such colormaps are found in palettable.

If you have installed palettable (formerly brewer2mpl), you can also access the discrete colormaps available to that package including those from colorbrewer. Install palettable with pip install palettable. To access these maps in yt, instead of supplying the colormap name, specify a tuple of the form (name, type, number), for example ('RdBu', 'Diverging', 9). These discrete colormaps will not be interpolated, and can be useful for creating colorblind/printer/grayscale-friendly plots. For more information, visit http://colorbrewer2.org.

Making and Viewing Custom Colormaps

yt can also accommodate custom colormaps using the make_colormap() function These custom colormaps can be made to an arbitrary level of complexity. You can make these on the fly for each yt session, or you can store them in your Plugin Files for access to them in every future yt session. The example below creates two custom colormaps, one that has three equally spaced bars of blue, white and red, and the other that interpolates in increasing lengthed intervals from black to red, to green, to blue. These will be accessible for the rest of the yt session as ‘french_flag’ and ‘weird’. See make_colormap() and show_colormaps() for more details.

yt.make_colormap(
    [("blue", 20), ("white", 20), ("red", 20)],
    name="french_flag",
    interpolate=False,
)
yt.make_colormap(
    [("black", 5), ("red", 10), ("green", 20), ("blue", 0)],
    name="weird",
    interpolate=True,
)
yt.show_colormaps(subset=["french_flag", "weird"], filename="cmaps.png")

All Colormaps (including matplotlib)

This is a chart of all of the yt and matplotlib colormaps available. In addition to each colormap displayed here, you can access its “reverse” by simply appending a "_r" to the end of the colormap name.

../../_images/all_colormaps.png

Native yt Colormaps

../../_images/native_yt_colormaps.png

Displaying Colormaps Locally

To display the most up to date colormaps locally, you can use the show_colormaps() function. By default, you’ll see every colormap available to you, but you can specify subsets of colormaps to display, either as just the yt_native colormaps, or by specifying a list of colormap names. This will display all the colormaps available in a local window:

import yt

yt.show_colormaps()

or to output the original yt colormaps to an image file, try:

import yt

yt.show_colormaps(
    subset=[
        "cmyt.algae",
        "cmyt.arbre",
        "cmyt.dusk",
        "cmyt.kelp",
        "cmyt.octarine",
        "cmyt.pastel",
    ],
    filename="yt_native.png",
)

Note

Since yt 4.1, yt native colormaps are shipped as a separate package cmyt that can be used outside yt itself. Within yt functions, these colormaps can still be referenced without the "cmyt." prefix. However, there is no guarantee that this will work in upcoming version of matplotlib, so our recommentation is to keep the prefix at all times to retain forward compatibility. yt also retains compatibility with names these colormaps were formerly known as (for instance cmyt.pastel used to be named kamae).

Applying a Colormap to your Rendering

All of the visualization functions in yt have a keyword allowing you to manually specify a specific colormap. For example:

yt.write_image(im, "output.png", cmap_name="jet")

If you’re using the Plot Window interface (e.g. SlicePlot, ProjectionPlot, etc.), it’s even easier than that. Simply create your rendering, and you can quickly swap the colormap on the fly after the fact with the set_cmap callback:

ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
p = yt.ProjectionPlot(ds, "z", ("gas", "density"))

p.set_cmap(field=("gas", "density"), cmap="turbo")
p.save("proj_with_jet_cmap.png")

p.set_cmap(field=("gas", "density"), cmap="hot")
p.save("proj_with_hot_cmap.png")

For more information about the callbacks available to Plot Window objects, see Plot Modifications: Overplotting Contours, Velocities, Particles, and More.

Examples of Each Colormap

To give the reader a better feel for how a colormap appears once it is applied to a dataset, below we provide a library of identical projections of an isolated galaxy where only the colormap has changed. They use the sample dataset “IsolatedGalaxy” available at https://yt-project.org/data.

../../_images/cmap_images__Projection_16_LEVEL.png ../../_images/cmap_images__Projection_16_LEVEL_r.png ../../_images/cmap_images__Projection_Accent.png ../../_images/cmap_images__Projection_Accent_r.png ../../_images/cmap_images__Projection_B-W_LINEAR.png ../../_images/cmap_images__Projection_B-W_LINEAR_r.png ../../_images/cmap_images__Projection_BLUE-RED.png ../../_images/cmap_images__Projection_BLUE-RED_r.png ../../_images/cmap_images__Projection_BLUE.png ../../_images/cmap_images__Projection_BLUE_r.png ../../_images/cmap_images__Projection_Beach.png ../../_images/cmap_images__Projection_Beach_r.png ../../_images/cmap_images__Projection_Blue-Red.png ../../_images/cmap_images__Projection_Blue-Red_r.png ../../_images/cmap_images__Projection_Blue_-_Pastel_-_Red.png ../../_images/cmap_images__Projection_Blue_-_Pastel_-_Red_r.png ../../_images/cmap_images__Projection_Blue_Waves.png ../../_images/cmap_images__Projection_Blue_Waves_r.png ../../_images/cmap_images__Projection_Blues.png ../../_images/cmap_images__Projection_Blues_r.png ../../_images/cmap_images__Projection_BrBG.png ../../_images/cmap_images__Projection_BrBG_r.png ../../_images/cmap_images__Projection_BuGn.png ../../_images/cmap_images__Projection_BuGn_r.png ../../_images/cmap_images__Projection_BuPu.png ../../_images/cmap_images__Projection_BuPu_r.png ../../_images/cmap_images__Projection_CMRmap.png ../../_images/cmap_images__Projection_CMRmap_r.png ../../_images/cmap_images__Projection_Dark2.png ../../_images/cmap_images__Projection_Dark2_r.png ../../_images/cmap_images__Projection_Eos_A.png ../../_images/cmap_images__Projection_Eos_A_r.png ../../_images/cmap_images__Projection_Eos_B.png ../../_images/cmap_images__Projection_Eos_B_r.png ../../_images/cmap_images__Projection_GREEN-PINK.png ../../_images/cmap_images__Projection_GREEN-PINK_r.png ../../_images/cmap_images__Projection_GREEN.png ../../_images/cmap_images__Projection_GREEN_r.png ../../_images/cmap_images__Projection_GRN-RED-BLU-WHT.png ../../_images/cmap_images__Projection_GRN-RED-BLU-WHT_r.png ../../_images/cmap_images__Projection_GRN.png ../../_images/cmap_images__Projection_GRN_r.png ../../_images/cmap_images__Projection_GnBu.png ../../_images/cmap_images__Projection_GnBu_r.png ../../_images/cmap_images__Projection_Grays.png ../../_images/cmap_images__Projection_Greens.png ../../_images/cmap_images__Projection_Greens_r.png ../../_images/cmap_images__Projection_Greys.png ../../_images/cmap_images__Projection_Greys_r.png ../../_images/cmap_images__Projection_Hardcandy.png ../../_images/cmap_images__Projection_Hardcandy_r.png ../../_images/cmap_images__Projection_Haze.png ../../_images/cmap_images__Projection_Haze_r.png ../../_images/cmap_images__Projection_Hue_Sat_Lightness_1.png ../../_images/cmap_images__Projection_Hue_Sat_Lightness_1_r.png ../../_images/cmap_images__Projection_Hue_Sat_Lightness_2.png ../../_images/cmap_images__Projection_Hue_Sat_Lightness_2_r.png ../../_images/cmap_images__Projection_Hue_Sat_Value_1.png ../../_images/cmap_images__Projection_Hue_Sat_Value_1_r.png ../../_images/cmap_images__Projection_Hue_Sat_Value_2.png ../../_images/cmap_images__Projection_Hue_Sat_Value_2_r.png ../../_images/cmap_images__Projection_Mac_Style.png ../../_images/cmap_images__Projection_Mac_Style_r.png ../../_images/cmap_images__Projection_Nature.png ../../_images/cmap_images__Projection_Nature_r.png ../../_images/cmap_images__Projection_Ocean.png ../../_images/cmap_images__Projection_Ocean_r.png ../../_images/cmap_images__Projection_OrRd.png ../../_images/cmap_images__Projection_OrRd_r.png ../../_images/cmap_images__Projection_Oranges.png ../../_images/cmap_images__Projection_Oranges_r.png ../../_images/cmap_images__Projection_PRGn.png ../../_images/cmap_images__Projection_PRGn_r.png ../../_images/cmap_images__Projection_PRISM.png ../../_images/cmap_images__Projection_PRISM_r.png ../../_images/cmap_images__Projection_Paired.png ../../_images/cmap_images__Projection_Paired_r.png ../../_images/cmap_images__Projection_Pastel1.png ../../_images/cmap_images__Projection_Pastel1_r.png ../../_images/cmap_images__Projection_Pastel2.png ../../_images/cmap_images__Projection_Pastel2_r.png ../../_images/cmap_images__Projection_Pastels.png ../../_images/cmap_images__Projection_Pastels_r.png ../../_images/cmap_images__Projection_Peppermint.png ../../_images/cmap_images__Projection_Peppermint_r.png ../../_images/cmap_images__Projection_PiYG.png ../../_images/cmap_images__Projection_PiYG_r.png ../../_images/cmap_images__Projection_Plasma.png ../../_images/cmap_images__Projection_Plasma_r.png ../../_images/cmap_images__Projection_PuBu.png ../../_images/cmap_images__Projection_PuBuGn.png ../../_images/cmap_images__Projection_PuBuGn_r.png ../../_images/cmap_images__Projection_PuBu_r.png ../../_images/cmap_images__Projection_PuOr.png ../../_images/cmap_images__Projection_PuOr_r.png ../../_images/cmap_images__Projection_PuRd.png ../../_images/cmap_images__Projection_PuRd_r.png ../../_images/cmap_images__Projection_Purple-Red_%2B_Stripes.png ../../_images/cmap_images__Projection_Purple-Red_%2B_Stripes_r.png ../../_images/cmap_images__Projection_Purples.png ../../_images/cmap_images__Projection_Purples_r.png ../../_images/cmap_images__Projection_RAINBOW.png ../../_images/cmap_images__Projection_RAINBOW_r.png ../../_images/cmap_images__Projection_RED-PURPLE.png ../../_images/cmap_images__Projection_RED-PURPLE_r.png ../../_images/cmap_images__Projection_RED_TEMPERATURE.png ../../_images/cmap_images__Projection_RED_TEMPERATURE_r.png ../../_images/cmap_images__Projection_Rainbow.png ../../_images/cmap_images__Projection_Rainbow18.png ../../_images/cmap_images__Projection_Rainbow18_r.png ../../_images/cmap_images__Projection_Rainbow_%2B_black.png ../../_images/cmap_images__Projection_Rainbow_%2B_black_r.png ../../_images/cmap_images__Projection_Rainbow_%2B_white.png ../../_images/cmap_images__Projection_Rainbow_%2B_white_r.png ../../_images/cmap_images__Projection_Rainbow_r.png ../../_images/cmap_images__Projection_RdBu.png ../../_images/cmap_images__Projection_RdBu_r.png ../../_images/cmap_images__Projection_RdGy.png ../../_images/cmap_images__Projection_RdGy_r.png ../../_images/cmap_images__Projection_RdPu.png ../../_images/cmap_images__Projection_RdPu_r.png ../../_images/cmap_images__Projection_RdYlBu.png ../../_images/cmap_images__Projection_RdYlBu_r.png ../../_images/cmap_images__Projection_RdYlGn.png ../../_images/cmap_images__Projection_RdYlGn_r.png ../../_images/cmap_images__Projection_Reds.png ../../_images/cmap_images__Projection_Reds_r.png ../../_images/cmap_images__Projection_STD_GAMMA-II.png ../../_images/cmap_images__Projection_STD_GAMMA-II_r.png ../../_images/cmap_images__Projection_STEPS.png ../../_images/cmap_images__Projection_STEPS_r.png ../../_images/cmap_images__Projection_STERN_SPECIAL.png ../../_images/cmap_images__Projection_STERN_SPECIAL_r.png ../../_images/cmap_images__Projection_Set1.png ../../_images/cmap_images__Projection_Set1_r.png ../../_images/cmap_images__Projection_Set2.png ../../_images/cmap_images__Projection_Set2_r.png ../../_images/cmap_images__Projection_Set3.png ../../_images/cmap_images__Projection_Set3_r.png ../../_images/cmap_images__Projection_Spectral.png ../../_images/cmap_images__Projection_Spectral_r.png ../../_images/cmap_images__Projection_Volcano.png ../../_images/cmap_images__Projection_Volcano_r.png ../../_images/cmap_images__Projection_Waves.png ../../_images/cmap_images__Projection_Waves_r.png ../../_images/cmap_images__Projection_Wistia.png ../../_images/cmap_images__Projection_Wistia_r.png ../../_images/cmap_images__Projection_YlGn.png ../../_images/cmap_images__Projection_YlGnBu.png ../../_images/cmap_images__Projection_YlGnBu_r.png ../../_images/cmap_images__Projection_YlGn_r.png ../../_images/cmap_images__Projection_YlOrBr.png ../../_images/cmap_images__Projection_YlOrBr_r.png ../../_images/cmap_images__Projection_YlOrRd.png ../../_images/cmap_images__Projection_YlOrRd_r.png ../../_images/cmap_images__Projection_afmhot.png ../../_images/cmap_images__Projection_afmhot_r.png ../../_images/cmap_images__Projection_algae.png ../../_images/cmap_images__Projection_algae_r.png ../../_images/cmap_images__Projection_arbre.png ../../_images/cmap_images__Projection_arbre_r.png ../../_images/cmap_images__Projection_autumn.png ../../_images/cmap_images__Projection_autumn_r.png ../../_images/cmap_images__Projection_bds_highcontrast.png ../../_images/cmap_images__Projection_bds_highcontrast_r.png ../../_images/cmap_images__Projection_binary.png ../../_images/cmap_images__Projection_binary_r.png ../../_images/cmap_images__Projection_black_blueish.png ../../_images/cmap_images__Projection_black_blueish_r.png ../../_images/cmap_images__Projection_black_green.png ../../_images/cmap_images__Projection_black_green_r.png ../../_images/cmap_images__Projection_bone.png ../../_images/cmap_images__Projection_bone_r.png ../../_images/cmap_images__Projection_brg.png ../../_images/cmap_images__Projection_brg_r.png ../../_images/cmap_images__Projection_bwr.png ../../_images/cmap_images__Projection_bwr_r.png ../../_images/cmap_images__Projection_cividis.png ../../_images/cmap_images__Projection_cividis_r.png ../../_images/cmap_images__Projection_cmyt.algae.png ../../_images/cmap_images__Projection_cmyt.algae_r.png ../../_images/cmap_images__Projection_cmyt.apricity.png ../../_images/cmap_images__Projection_cmyt.apricity_r.png ../../_images/cmap_images__Projection_cmyt.arbre.png ../../_images/cmap_images__Projection_cmyt.arbre_r.png ../../_images/cmap_images__Projection_cmyt.dusk.png ../../_images/cmap_images__Projection_cmyt.dusk_r.png ../../_images/cmap_images__Projection_cmyt.kelp.png ../../_images/cmap_images__Projection_cmyt.kelp_r.png ../../_images/cmap_images__Projection_cmyt.octarine.png ../../_images/cmap_images__Projection_cmyt.octarine_r.png ../../_images/cmap_images__Projection_cmyt.pastel.png ../../_images/cmap_images__Projection_cmyt.pastel_r.png ../../_images/cmap_images__Projection_cmyt.pixel_blue.png ../../_images/cmap_images__Projection_cmyt.pixel_blue_r.png ../../_images/cmap_images__Projection_cmyt.pixel_green.png ../../_images/cmap_images__Projection_cmyt.pixel_green_r.png ../../_images/cmap_images__Projection_cmyt.pixel_red.png ../../_images/cmap_images__Projection_cmyt.pixel_red_r.png ../../_images/cmap_images__Projection_cmyt.xray.png ../../_images/cmap_images__Projection_cmyt.xray_r.png ../../_images/cmap_images__Projection_cool.png ../../_images/cmap_images__Projection_cool_r.png ../../_images/cmap_images__Projection_coolwarm.png ../../_images/cmap_images__Projection_coolwarm_r.png ../../_images/cmap_images__Projection_copper.png ../../_images/cmap_images__Projection_copper_r.png ../../_images/cmap_images__Projection_cubehelix.png ../../_images/cmap_images__Projection_cubehelix_r.png ../../_images/cmap_images__Projection_doom.png ../../_images/cmap_images__Projection_doom_r.png ../../_images/cmap_images__Projection_dusk.png ../../_images/cmap_images__Projection_dusk_r.png ../../_images/cmap_images__Projection_flag.png ../../_images/cmap_images__Projection_flag_r.png ../../_images/cmap_images__Projection_gist_earth.png ../../_images/cmap_images__Projection_gist_earth_r.png ../../_images/cmap_images__Projection_gist_gray.png ../../_images/cmap_images__Projection_gist_gray_r.png ../../_images/cmap_images__Projection_gist_grey.png ../../_images/cmap_images__Projection_gist_heat.png ../../_images/cmap_images__Projection_gist_heat_r.png ../../_images/cmap_images__Projection_gist_ncar.png ../../_images/cmap_images__Projection_gist_ncar_r.png ../../_images/cmap_images__Projection_gist_rainbow.png ../../_images/cmap_images__Projection_gist_rainbow_r.png ../../_images/cmap_images__Projection_gist_stern.png ../../_images/cmap_images__Projection_gist_stern_r.png ../../_images/cmap_images__Projection_gist_yarg.png ../../_images/cmap_images__Projection_gist_yarg_r.png ../../_images/cmap_images__Projection_gist_yerg.png ../../_images/cmap_images__Projection_gnuplot.png ../../_images/cmap_images__Projection_gnuplot2.png ../../_images/cmap_images__Projection_gnuplot2_r.png ../../_images/cmap_images__Projection_gnuplot_r.png ../../_images/cmap_images__Projection_gray.png ../../_images/cmap_images__Projection_gray_r.png ../../_images/cmap_images__Projection_grey.png ../../_images/cmap_images__Projection_hot.png ../../_images/cmap_images__Projection_hot_r.png ../../_images/cmap_images__Projection_hsv.png ../../_images/cmap_images__Projection_hsv_r.png ../../_images/cmap_images__Projection_inferno.png ../../_images/cmap_images__Projection_inferno_r.png ../../_images/cmap_images__Projection_jet.png ../../_images/cmap_images__Projection_jet_r.png ../../_images/cmap_images__Projection_kamae.png ../../_images/cmap_images__Projection_kamae_r.png ../../_images/cmap_images__Projection_kelp.png ../../_images/cmap_images__Projection_kelp_r.png ../../_images/cmap_images__Projection_magma.png ../../_images/cmap_images__Projection_magma_r.png ../../_images/cmap_images__Projection_nipy_spectral.png ../../_images/cmap_images__Projection_nipy_spectral_r.png ../../_images/cmap_images__Projection_ocean.png ../../_images/cmap_images__Projection_ocean_r.png ../../_images/cmap_images__Projection_octarine.png ../../_images/cmap_images__Projection_octarine_r.png ../../_images/cmap_images__Projection_pink.png ../../_images/cmap_images__Projection_pink_r.png ../../_images/cmap_images__Projection_plasma.png ../../_images/cmap_images__Projection_plasma_r.png ../../_images/cmap_images__Projection_prism.png ../../_images/cmap_images__Projection_prism_r.png ../../_images/cmap_images__Projection_purple_mm.png ../../_images/cmap_images__Projection_purple_mm_r.png ../../_images/cmap_images__Projection_rainbow.png ../../_images/cmap_images__Projection_rainbow_r.png ../../_images/cmap_images__Projection_seismic.png ../../_images/cmap_images__Projection_seismic_r.png ../../_images/cmap_images__Projection_spring.png ../../_images/cmap_images__Projection_spring_r.png ../../_images/cmap_images__Projection_summer.png ../../_images/cmap_images__Projection_summer_r.png ../../_images/cmap_images__Projection_tab10.png ../../_images/cmap_images__Projection_tab10_r.png ../../_images/cmap_images__Projection_tab20.png ../../_images/cmap_images__Projection_tab20_r.png ../../_images/cmap_images__Projection_tab20b.png ../../_images/cmap_images__Projection_tab20b_r.png ../../_images/cmap_images__Projection_tab20c.png ../../_images/cmap_images__Projection_tab20c_r.png ../../_images/cmap_images__Projection_terrain.png ../../_images/cmap_images__Projection_terrain_r.png ../../_images/cmap_images__Projection_turbo.png ../../_images/cmap_images__Projection_turbo_r.png ../../_images/cmap_images__Projection_twilight.png ../../_images/cmap_images__Projection_twilight_r.png ../../_images/cmap_images__Projection_twilight_shifted.png ../../_images/cmap_images__Projection_twilight_shifted_r.png ../../_images/cmap_images__Projection_viridis.png ../../_images/cmap_images__Projection_viridis_r.png ../../_images/cmap_images__Projection_winter.png ../../_images/cmap_images__Projection_winter_r.png