Functions that are metrics on the x-axis but not metrics on R^2 as a whole?

Are there functions that can be defined on $$\mathbb{R}^2$$, are metrics on the whole x-axis (i.e, the set of all points whose second coordinates are $$0$$), but not metrics on $$\mathbb{R}^2$$ as a whole? I am especially wondering about the existence of the ones that break the triangle inequality.

More generally, are there functions that can be defined on $$\mathbb{R}^2$$, but are metrics only on a few straight lines or some other subsets of $$\mathbb{R}^2$$, but not on $$\mathbb{R}^2$$ as a whole?

Thanks!

Edit:

I guess some piecewise functions may fit the description. For example, we let $$d = |x - y|$$ only on $$[-1, 1] \times [-1, 1]$$, but let $$d = (x - y) ^ 2$$ elsewhere on $$\mathbb{R}^2$$. However, I was looking for "non-piecewise" functions.

You can take $$d\bigl((x,y),(z,t)\bigr)=|x-z|+(y-t)^2$$. The restriction to $$\{(x,0)\mid x\in\Bbb R\}$$ is the usual distance there. But\begin{align}d\bigl((0,0),(0,1)\bigr)+d\bigl((0,1),(0,2)\bigr)&=2\\&<4\\&=d\bigl((0,0),(0,2)\bigr).\end{align}