I recently found a way to do this by messing around. Here is the trick.
Lets use your question as an example;
To restrict the domain of y=2*x where x=[2,4]
Go to Mathstudio and type:
Thats all there is to it!
If you would like to know more on how this works or to use the script I created to make it simple to use, click the DomainPlotv1.math file.
P.S. I uploaded it to the share section (I Think).
DomainPlot v1.math (2.4 KB)