I have created an accessible grayscale color palette choosing AAA and AA colors with the following colors.

Palette system

The colors are interchangeable between each other, over black and white background, so you can swipe them using variables by code, or just choosing YW / YB respectively to get a very similar contrast.

Application

As you can see in the following example, it can be applied to any visual media, obviously taking into consideration other accessibility guidelines, as font size, weight, etc…

Attribution 4.0 International (CC BY 4.0)