**WARNING: INCORRECT see comments for why** If f is continuous on some connected sets it must be monotonic on them. Say it is not. Then there is some point $x^*$ such that in some of its neighborhood V such that $x^*=\sup_V f$. Then it can be shown easily that there are $x_1,x_2$ in some neighborhood of $x^*$ such that $f(x_1)=f(x_2)$ and $d(x_1,x_2)\lt 1$ causing a contradiction. note: here monotone is defined as that there is no $x^*$ such that it is the superior of all $f(x)$ in some of its neighborhood, which can be shown to be equivalent to the concept of monotone in real valued functions of one real variable.