f[x_]:= Piecewise[{
{x^2,x<0},
{x,x>0}
}];

Plot[f[x],{x,-2,2}]