demo_reverse Program

Uses

  • program~~demo_reverse~~UsesGraph program~demo_reverse demo_reverse forcolormap_utils forcolormap_utils program~demo_reverse->forcolormap_utils module~forcolormap forcolormap program~demo_reverse->module~forcolormap module~colormap_parameters colormap_parameters module~forcolormap->module~colormap_parameters module~matplotlib_colormaps matplotlib_colormaps module~forcolormap->module~matplotlib_colormaps module~miscellaneous_colormaps miscellaneous_colormaps module~forcolormap->module~miscellaneous_colormaps module~scientific_colour_maps scientific_colour_maps module~forcolormap->module~scientific_colour_maps iso_fortran_env iso_fortran_env module~colormap_parameters->iso_fortran_env module~matplotlib_colormaps->module~colormap_parameters module~miscellaneous_colormaps->module~colormap_parameters module~scientific_colour_maps->module~colormap_parameters

This example demonstrates the use of the 'reverse' optional argument to reverse the order of a colormap. You can create your own colormap using that array. The name of your colormap must conform to the max length defined in colormap_parameters.f90 Use the create() method instead of the set() method. We create PPM files (binary encoded by default) for each built-in colormap. The built-in z=f(x,y) test function is in the [0, 2] range: Cubehelix can also accept other parameters (varargs array):

Or you can download it from a .txt file. Use the load() method instead of the set() method.


Calls

program~~demo_reverse~~CallsGraph program~demo_reverse demo_reverse proc~create Colormap%create program~demo_reverse->proc~create proc~get_levels Colormap%get_levels program~demo_reverse->proc~get_levels proc~get_name Colormap%get_name program~demo_reverse->proc~get_name proc~load Colormap%load program~demo_reverse->proc~load proc~set Colormap%set program~demo_reverse->proc~set proc~write_ppm_colorbar Colormap%write_ppm_colorbar program~demo_reverse->proc~write_ppm_colorbar test_colormap test_colormap program~demo_reverse->test_colormap proc~check Colormap%check proc~create->proc~check proc~reverse Colormap%reverse proc~create->proc~reverse proc~load->proc~check proc~load->proc~reverse proc~set->proc~create proc~set->proc~check proc~cubehelix_colormap cubehelix_colormap proc~set->proc~cubehelix_colormap proc~fire_colormap fire_colormap proc~set->proc~fire_colormap proc~inv_rainbow_colormap inv_rainbow_colormap proc~set->proc~inv_rainbow_colormap proc~rainbow_colormap rainbow_colormap proc~set->proc~rainbow_colormap proc~set->proc~reverse proc~zebra_colormap zebra_colormap proc~set->proc~zebra_colormap export_pnm export_pnm proc~write_ppm_colorbar->export_pnm get_format get_format proc~write_ppm_colorbar->get_format proc~compute_rgb Colormap%compute_RGB proc~write_ppm_colorbar->proc~compute_rgb proc~get_zmax Colormap%get_zmax proc~write_ppm_colorbar->proc~get_zmax proc~get_zmin Colormap%get_zmin proc~write_ppm_colorbar->proc~get_zmin set_format set_format proc~write_ppm_colorbar->set_format set_pnm set_pnm proc~write_ppm_colorbar->set_pnm proc~get_levels~2 Colormaps_info%get_levels proc~check->proc~get_levels~2 proc~get_name~2 Colormaps_info%get_name proc~check->proc~get_name~2 proc~get_ncolormaps Colormaps_info%get_ncolormaps proc~check->proc~get_ncolormaps proc~set_all Colormaps_info%set_all proc~check->proc~set_all proc~get_rgb Colormap%get_RGB proc~compute_rgb->proc~get_rgb proc~set_info table%set_info proc~set_all->proc~set_info

Variables

Type Attributes Name Initial
type(Colormap) :: cmap
type(Colormap) :: custom_cmap
integer :: i
integer, dimension(0:7, 3) :: my_colormap = reshape([198, 29, 32, 189, 21, 56, 171, 82, 150, 102, 81, 156, 38, 53, 108, 5, 65, 40, 221, 199, 44, 237, 191, 44], shape(my_colormap), order=[2, 1])

A discrete colormap with 8 levels, by @alozada, resembling the color changes in red cabbage (containing Anthocyanins) with pH:


Source Code

program demo_reverse
    use forcolormap, only: Colormap, colormaps_list, wp
    use forcolormap_utils, only: test_colormap
    implicit none

    integer :: i
    type(Colormap) :: cmap, custom_cmap

    !> A discrete colormap with 8 levels, by @alozada, resembling the color
    !> changes in red cabbage (containing Anthocyanins) with pH:
    integer, dimension(0:7, 3) :: my_colormap = reshape( [ &
        198,    29,    32,   &
        189,    21,    56,   &
        171,    82,   150,   &
        102,    81,   156,   &
         38,    53,   108,   &
          5,    65,    40,   &
        221,   199,    44,   &
        237,   191,    44 ], &
        shape(my_colormap), order = [2, 1] )
    !> You can create your own colormap using that array. The name of your
    !> colormap must conform to the max length defined in colormap_parameters.f90
    !> Use the create() method instead of the set() method.
    call custom_cmap%create('red_cabbage_reverse', 0.0_wp, 2.0_wp, my_colormap, reverse=.true.)
    call custom_cmap%colorbar('red_cabbage_reverse_colorbar')
    call test_colormap(custom_cmap, 'red_cabbage_reverse_test')

    !> We create PPM files (binary encoded by default) for each built-in colormap.
    !> The built-in z=f(x,y) test function is in the [0, 2] range:
    do i = 1, size(colormaps_list)
        call cmap%set(trim(colormaps_list(i)), 0.0_wp, 2.0_wp, reverse=.true.)
        call cmap%colorbar(trim(colormaps_list(i))//'_reverse_colorbar')
        call test_colormap(cmap, trim(colormaps_list(i))//'_reverse_test')
        print '("Colormap ", A30, " has ", I0, " levels")', trim(cmap%get_name()), cmap%get_levels()
    end do

    !> Cubehelix can also accept other parameters (varargs array):
    call cmap%set("cubehelix", 0.0_wp, 2.0_wp, 1024, [0.5_wp, -1.0_wp, 1.0_wp, 1.0_wp], reverse=.true.)
    ! We change the name for the output test files:
    call cmap%colorbar('cubehelix_customized_reverse_colorbar')
    call test_colormap(cmap, 'cubehelix_customized_reverse_test')

    !> Or you can download it from a .txt file.
    !> Use the load() method instead of the set() method.
    call custom_cmap%load("test_map_to_load.txt", 0.0_wp, 2.0_wp, reverse=.true.)
    call custom_cmap%colorbar('a_loaded_reverse_colorbar')
    call test_colormap(custom_cmap, 'a_loaded_reverse_colormap_test')
    call custom_cmap%print()

end program demo_reverse