Skip to content

Commit

Permalink
examples: binary encoding is the default for colorbars
Browse files Browse the repository at this point in the history
  • Loading branch information
vmagnin committed Feb 15, 2024
1 parent 9f9f53c commit db16e86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions example/demo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! SOFTWARE.
!-------------------------------------------------------------------------------
! Contributed by vmagnin: 2023-09-26
! Last modification: gha3mi 2024-01-28
! Last modification: gha3mi 2024-01-28, vmagnin 2024-02-15
!-------------------------------------------------------------------------------

program demo
Expand All @@ -47,25 +47,25 @@ program demo
! 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)
call cmap%colorbar(trim(colormaps_list(i))//'_colorbar', encoding='binary')
call cmap%colorbar(trim(colormaps_list(i))//'_colorbar')
call test_colormap(cmap, trim(colormaps_list(i))//'_test', encoding='binary')
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])
! We change the name for the output test files:
call cmap%colorbar('cubehelix_customized_colorbar', encoding='binary')
call cmap%colorbar('cubehelix_customized_colorbar')
call test_colormap(cmap, 'cubehelix_customized_test', encoding='binary')

! You can create your own colormap defined in an array:
call custom_cmap%create('discrete', 0.0_wp, 2.0_wp, my_colormap)
call custom_cmap%colorbar('discrete_colorbar', encoding='binary')
call custom_cmap%colorbar('discrete_colorbar')
call test_colormap(custom_cmap, 'discrete_test', encoding='binary')

! Or you can download it from a .txt file:
call custom_cmap%load("test_map_to_load.txt", 0.0_wp, 2.0_wp)
call custom_cmap%colorbar('a_loaded_colorbar', encoding='binary')
call custom_cmap%colorbar('a_loaded_colorbar')
call test_colormap(custom_cmap, 'a_loaded_colormap_test', encoding='binary')
call custom_cmap%print()

Expand All @@ -76,7 +76,7 @@ program demo
colors(2,:) = [0, 255, 0] ! Green
colors(3,:) = [0, 0, 255] ! Blue
call custom_cmap%create('custom_bezier', 0.0_wp, 2.0_wp, bezier(colors, levels=1024)) ! levels is optional, default is 256
call custom_cmap%colorbar('custom_colorbar_bezier', encoding='binary')
call custom_cmap%colorbar('custom_colorbar_bezier')
call test_colormap(custom_cmap, 'custom_test_bezier', encoding='binary')

contains
Expand Down
10 changes: 5 additions & 5 deletions example/demo_reverse.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! SOFTWARE.
!-------------------------------------------------------------------------------
! Contributed by vmagnin: 2023-09-26
! Last modification: gha3mi 2023-11-01
! Last modification: gha3mi 2023-11-01, vmagnin 2024-02-15
!-------------------------------------------------------------------------------

program demo_reverse
Expand All @@ -46,25 +46,25 @@ program demo_reverse
! 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', encoding='binary')
call cmap%colorbar(trim(colormaps_list(i))//'_reverse_colorbar')
call test_colormap(cmap, trim(colormaps_list(i))//'_reverse_test', encoding='binary')
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', encoding='binary')
call cmap%colorbar('cubehelix_customized_reverse_colorbar')
call test_colormap(cmap, 'cubehelix_customized_reverse_test', encoding='binary')

! You can create your own colormap defined in an array:
call custom_cmap%create('discrete', 0.0_wp, 2.0_wp, my_colormap, reverse=.true.)
call custom_cmap%colorbar('discrete_reverse_colorbar', encoding='binary')
call custom_cmap%colorbar('discrete_reverse_colorbar')
call test_colormap(custom_cmap, 'discrete_reverse_test', encoding='binary')

! Or you can download it from a .txt file:
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', encoding='binary')
call custom_cmap%colorbar('a_loaded_reverse_colorbar')
call test_colormap(custom_cmap, 'a_loaded_reverse_colormap_test', encoding='binary')
call custom_cmap%print()

Expand Down
8 changes: 4 additions & 4 deletions example/extract.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
! SOFTWARE.
!-------------------------------------------------------------------------------
! Contributed by gha3mi: 2023-11-07
! Last modification: gha3mi 2023-11-07
! Last modification: gha3mi 2023-11-07, vmagnin 2024-02-15
!-------------------------------------------------------------------------------

! This example demonstrates the process of extracting a specified number of colors.
Expand All @@ -42,7 +42,7 @@ program extract
! The extracted colormap will overwrite the existing colormap type (cmap)
call cmap%extract(10)

! Generate a color bar for the extracted colormap with binary encoding
call cmap%colorbar('fes10_ex_colorbar', encoding='binary')
! Generate a color bar for the extracted colormap
call cmap%colorbar('fes10_ex_colorbar')

end program extract

0 comments on commit db16e86

Please sign in to comment.