function calendar_grid_plot ( s )

%*****************************************************************************80
%
%% calendar_grid_plot() plots the calendar grid boundary word.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 August 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    char s(*): a string of the characters 'u', 'd', 'l' and 'r' that should
%    represent a path around the boundary of the grid.
%
  check = boundary_word_check ( s );
  if ( ~ check )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'calendar_grid_plot - Fatal error!\n' );
    fprintf ( 1, '  Input boundary word "%s" is illegal.\n', s );
    return
  end

  [ xpoly, ypoly ] = boundary_word_boundary ( s );

  [ xmin, xmax, ymin, ymax ] = boundary_word_range ( s );

  label = calendar_labels ( );

  clf ( );
  hold ( 'on' );

  k = 0;
  for y = ymax - 1 : -1 : ymin
    for x = xmin : xmax - 1
      interior = polygon_contains_point ( xpoly, ypoly, x+0.5, y+0.5 );
      if ( interior )
        plot ( [ x, x+1, x+1, x, x ], [ y, y, y+1, y+1, y ], 'k-' );
        k = k + 1;
        text ( x+0.5, y+0.5, label{k}, 'HorizontalAlignment', 'center' );
      end
    end
  end

  title ( 'Calendar puzzle grid', 'Fontsize', 16 );
  hold ( 'off' );
  axis ( 'equal' );
  axis ( 'off' );

  return
end

