I would like to change options in attribute settings as follows:

1. Color : Red
Blue
Black

2. Size : X
XL
XXL


when red color is selected, only X and XL should be displayed in Size selection, Blue color, All 3 options, Black color, X and XXL should be displayed for selection.

How can I set up this scenario in attributes?