Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

For some reason I need to create a chess board. I can create a chess board by following command:

  EdgeForm[Thick], Black, Rectangle[{0, 0}],
  EdgeForm[Thick], White, Rectangle[{1, 0}],
  EdgeForm[Thick], , Black, Rectangle[{2, 0}],

  EdgeForm[Thick], White, Rectangle[{0, 1}],
  EdgeForm[Thick], Black, Rectangle[{1, 1}],
  EdgeForm[Thick], White, Rectangle[{2, 1}],

  EdgeForm[Thick], Black, Rectangle[{0, 2}],
  EdgeForm[Thick], White, Rectangle[{1, 2}],
  EdgeForm[Thick], , Black, Rectangle[{2, 2}],


Problem is it has to be resizable (Manipulate command). And I should put the numbers for columns and rows. I am going to give one parameter such as board size. The code will generate the board. I believe there is a code for that, but I couldn't find on the internet. Thanks for the help.

This is an example, chess board.

Example chess board

share|improve this question
Welcome! The reason is not by any chance homework? Then you should add the homework or assignment tag. –  Yves Klett May 7 at 18:53

1 Answer 1

up vote 10 down vote accepted
Manipulate[MatrixPlot[Table[Mod[i + j, 2], {i, 1, n}, {j, 1, n}], ColorFunction -> "Monochrome"], {{n, 8}, 1, 20}]

enter image description here

Nice and simple.

With correct column numbering, thanks to a shameless steal from Kuba:

 MatrixPlot[Table[Mod[i + j, 2], {i, 1, n}, {j, 1, n}], 
  ColorFunction -> "Monochrome", 
  FrameTicks -> {Range@n,Transpose[{#, FromCharacterCode /@ (# + 96)} &[Range[n]]]}], {{n, 8}, 1, 20}]
share|improve this answer
Thank you so much for the code. :) Now, I need to put queen pictures some of the squares. Is there any quick way to do it? –  forumcash May 7 at 20:25
You could use Show[] –  nickjamesuk May 7 at 20:28
@user14114 \[WhiteQueen] and \[BlackQueen] are the characters you need. –  Sjoerd C. de Vries May 7 at 20:59
I didn't know these commands. Thanks for these commands. However, I need queens on the board. How can I put queens together with background? –  forumcash May 8 at 14:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.