# How can I draw several diagonal squares?

I'm the beginner in Mathematica Plot, so I recently met many situations that I could not understand. Here is my code for drawing 10 squares across the diagonal line in a square:

RegionPlot[{x - y <= 0.1 && y - x <= 0.1 && 0 <= x <= 0.1 &&
0 <= y <= 0.1, x - y <= 0.1 && y - x <= 0.1 && 0.1 <= x <= 0.2 && 0.1 <= y <= 0.2,
x - y <= 0.1 && y - x <= 0.1 && 0.2 <= x <= 0.3 && 0.2 <= y <= 0.3,
x - y <= 0.1 && y - x <= 0.1 && 0.3 <= x <= 0.4 && 0.3 <= y <= 0.4，
x - y <= 0.1 && y - x <= 0.1 && 0.4 <= x <= 0.5 && 0.4 <= y <= 0.5，
x - y <= 0.1 && y - x <= 0.1 && 0.5 <= x <= 0.6 &&0.5 <= y <= 0.6，
x - y <= 0.1 && y - x <= 0.1 && 0.6 <= x <= 0.7 &&0.6 <= y <= 0.7，
x - y <= 0.1 && y - x <= 0.1 && 0.7 <= x <= 0.8 &&0.7 <= y <= 0.8，
x - y <= 0.1 && y - x <= 0.1 && 0.8 <= x <= 0.9 &&0.8 <= y <= 0.9，
x - y <= 0.1 && y - x <= 0.1 && 0.9 <= x <= 1.0 &&0.9 <= y <= 1.0},
{x, 0, 1}, {y, 0, 1}, PlotStyle -> Blue,PlotPoints -> 100, MaxRecursion -> 10,
FrameLabel -> {"\!$$\*SubscriptBox[\(p$$, $$1$$]\)", "\!$$\*SubscriptBox[\(p$$, $$2$$]\)"}, BoundaryStyle -> None]


But it gives me three squares:

Where are the other seven squares?

• Your input data contains irregular symbol after the third square. That's why. Commented Aug 20, 2022 at 0:16
• The ， is wrong. Please use a suitable editor. Commented Aug 20, 2022 at 0:22
• Yes, that's it, it's not very obvious on my laptop, but become clear in the quote mode! Thank you so much! Commented Aug 20, 2022 at 0:24

ArrayMesh make the task easy.

m = Reverse@SparseArray[{Band[{1, 1}] -> 1}, {10, 10}];
m // MatrixForm
ArrayMesh[m, DataRange -> {{0, 1}, {0, 1}},
MeshCellStyle -> {{2, ;;} -> Blue}, PlotTheme -> "Detailed"]


Or

ArrayMesh[SparseArray[{{x_, y_} /; x + y == 10 -> 1}, {10, 10}],
DataRange -> {{0, 1}, {0, 1}},
MeshCellStyle -> {2 -> Green, 1 -> Red}, PlotTheme -> "Detailed"]


RegionPlot[
y > Floor[x, 0.1] && y < Ceiling[x, 0.1], {x, 0, 1}, {y, 0, 1},
PlotPoints -> 100]


m = Reverse@SparseArray[{Band[{1, 1}] -> 1}, {10, 10}];
MatrixPlot[m, ColorRules -> {1 -> Blue}]


• Nice : would work with IdentityMatrix too Commented Aug 20, 2022 at 8:35