You mean legalizing some drugs.
Believe it or not, some people out there do obey the law. Legalizing recreational drug A would mitigate the gateway effect to illegal recreational drug B.
But, legalizing recreational drug A would increase the number of users of drug A, and some of them would go on to drug B despite its illegality.
So, it's hard to say how legalization would impact the overall "gateway effect".
So you admit that the "gateway effect" that you hypothesize is correlated to the legality of the "gateway drug". Interesting.
But, legalizing recreational drug A would increase the number of users of drug A, and some of them would go on to drug B despite its illegality.
But if the "gateway effect" is mitigated, it will be at a lower rate than currently and thus increased use of drug A might not cause increased use of drug B, and may in fact lower it?
So your call for marijuana remaining illegal may result in more people addicted to heroin.
For those users, if the illegality of drug B is not a deterrent, then criminalizing drug A won't keep them from using it either.