Can a nowhere continuous function have a connected graph? After noticing that function $f: \mathbb R\rightarrow \mathbb R $ $$ f(x) = \left\{\begin{array}{l} \sin\frac{1}{x} & \text{for }x\neq 0 \\ 0 &\text{for }x=0 \end{array}\right. $$
has a graph that is a connected set, despite the function not being continuous at $x=0$, I started wondering, doest there exist a function $f: X\rightarrow Y$ that is nowhere continuous, but still has a connected graph?
I would like to consider three cases 


*

*$X$ and $Y$ being general topological spaces

*$X$ and $Y$ being Hausdorff spaces

*ADDED: $X=Y=\mathbb R$
But if you have answer for other, more specific cases, they may be interesting too.
 A: Here is an example for $\mathbb R^2 \to \mathbb R$:
$$f(x,y) = \begin{cases} y & \text{when }x=0\text{ or }x=1 \\
x & \text{when }x\in(0,1)\text{ and }y=0 \\
1-x &\text{when }x\in(0,1)\text{ and } y=x(1-x) \\
x(1-x) & \text{when }x\notin\{0,1\}\text{ and } y/x(1-x) \notin\mathbb  Q \\
0 & \text{otherwise} \end{cases} $$
This is easily seen to be everywhere discontinuous. But its graph is path-connected.

A similar but simpler construction, also $\mathbb R^2\to\mathbb R$:
$$ \begin{align} g(1 + r\cos\theta, r\sin\theta) = r & \quad\text{for }r>0,\; \theta\in\mathbb Q\cap[0,\pi] \\
g(r\cos\theta, r\sin\theta) =r & \quad \text{for }r>0,\; \theta\in\mathbb Q\cap[\pi,2\pi] \\
g(x,y)  =0 & \quad\text{everywhere else} \end{align} $$
A: Check out this paper:
F. B. Jones, Totally discontinuous linear functions whose graphs are connected, November 23, (1940). 
Abstract:

Cauchy discovered before 1821 that a function satisfying the equation
  $$
f(x)+f(y)=f(x+y)
$$
  is either continuous or totally discontinuous. After Hamel showed the existence of a discontinuous function, many mathematicians have concerned themselves with problems arising from the study of such functions. However, the following question seems to have gone unanswered: Since the plane image of such a function (the graph of $y =f(x)$) must either be connected or be
  totally disconnected, must the function be continuous if its image is connected? The answer is no. 

In particular, Theorem 5 presents a nowhere continuous function $f:\Bbb R \rightarrow \Bbb R$ whose graph is connected.

 Whether Conway base 13 function is such an example remains unknown. (at least on MSE; see Is the graph of the Conway base 13 function connected?)  It turns out the graph of Conway base 13 function is totally disconnected. See this brilliant answer. 
A: There is a simple general strategy for many questions of this type, which is to just try to build a counterexample by transfinite induction.  Let's first think about what it means for the graph $G$ of a function $f:\mathbb{R}\to\mathbb{R}$ to be disconnected.  It means there are open sets $U,V\subset\mathbb{R}^2$ such that $U\cap G$ and $V\cap G$ are both nonempty and together they form a partition of $G$ (we will say $(U,V)$ separates $G$ in that case).  So, to make $G$ connected, we just have to one-by-one rule out every such pair $(U,V)$ from separating it.
So, then, here is the construction.  Fix an enumeration $(U_\alpha,V_\alpha)_{\alpha<\mathfrak{c}}$ of all pairs of open subsets of $\mathbb{R}^2$.  By a transfinite recursion of length $\mathfrak{c}$ we define values of a function $f:\mathbb{R}\to\mathbb{R}$.  At the $\alpha$th step, we add a new value of $f$ to prevent $(U_\alpha,V_\alpha)$ from separating the graph of $f$, if necessary.  How do we do that?  Well, if possible, we define a new value of $f$ such that the corresponding point in the graph $G$ will either be in $U_\alpha\cap V_\alpha$ or not be in $U_\alpha\cup V_\alpha$, so $U_\alpha\cap G$ and $V_\alpha\cap G$ will not partition $G$.
If this is not possible, then $U_\alpha$ and $V_\alpha$ must partition $A\times\mathbb{R}$ where $A\subseteq\mathbb{R}$ is the set of points where we have not yet defined $f$.  Since $\mathbb{R}$ is connected, this means we can partition $A$ into sets $B$ and $C$ (both open in $A$) such that $U_\alpha\cap (A\times\mathbb{R})=B\times\mathbb{R}$ and $V_\alpha\cap (A\times\mathbb{R})=C\times\mathbb{R}$.  Now since we have defined fewer than $\mathfrak{c}$ values of $f$ so far in this construction, $|\mathbb{R}\setminus A|<\mathfrak{c}$ and in particular $A$ is dense in $\mathbb{R}$.  If $B$ were empty, then $U_\alpha$ would have empty interior and thus would be empty, and so $(U_\alpha,V_\alpha)$ can never separate the graph of $f$.  A similar conclusion holds if $C$ is empty, so let us assume both $B$ and $C$ are nonempty.  It follows that $\overline{B}$ and $\overline{C}$ cannot be disjoint (otherwise they would be a nontrivial partition of $\mathbb{R}$ into closed subsets), so there is a point $x\in\mathbb{R}\setminus A$ that is an accumulation point of both $B$ and $C$.  Since $x\not\in A$, we have already defined $f(x)$.  Note now that $(x,f(x))\not\in U_\alpha$, since $U_\alpha$ would then contain an open ball around $(x,f(x))$ and thus would intersect $C\times\mathbb{R}$.  Similarly, $(x,f(x))\not\in V_\alpha$.  Thus $U_\alpha$ and $V_\alpha$ already do not contain the entire graph of $f$, and so we do not need to do anything to prevent them from separating it.
At the end of this construction we will have a partial function $\mathbb{R}\to\mathbb{R}$ such that by construction, its graph is not separated by any pair of open subsets of $\mathbb{R}^2$, and the same is guaranteed to hold for any extension of our function.  Extending to a total function, we get a total function $f:\mathbb{R}\to\mathbb{R}$ whose graph is connected.  But we can of course arrange in this construction for $f$ to be nowhere continuous; for instance, we could start out by defining $f$ on all the rationals so that the image of every open interval is dense in $\mathbb{R}$.  In fact, the construction shows that any partial function $\mathbb{R}\to\mathbb{R}$ defined on a set of cardinality less than $\mathfrak{c}$ can be extended to a total function whose graph is connected.  (Or even stronger, you could start with any partial function whose domain omits $\mathfrak{c}$ points from every interval, since that is all you need to guarantee that the set $A$ is dense at each step.)
A: Not an answer
Great question, and I don't have an answer for you, but I've got some small thoughts:
By summing up weighted and displaced copies of $f$, you can get discontinuities at many places. For instance, you could write
$$
F(x) = \sum_{n \in \Bbb Z} \frac{f(x-n)}{1+n^2}
$$
That'll have an $f$-like discontinuity at every integer.
Digression
A comment asks whether the graph is still connected. Let me show that it is at $x = 1$ as an example, which should be reasonably compelling for other integer points. (For non-integer points, $F$ is continuous, so we're fine). 
Write 
\begin{align}
F(x) &= \frac{1}{2} f(x-1) + \sum_{n\ne 1 \in \Bbb Z} \frac{f(x-n)}{1+n^2}\\
 &= \frac{1}{2} f(x-1) + G_1(x)
\end{align}
where $G_1$ is a function that's continuous at $x = 1$. 
Let's look at the graph of $F$ near $1$, say on the interval $(3/4, 5/4)$. It's exactly 
$$
K = \{ (x, \frac{1}{2} f(x-1) + G_1(x)) \mid 3/4 < x < 5/4 \}
$$
Contrast this with the graph of $f$ near $0$, which is 
$$
H = \{ (x, f(x)) \mid -1/4 < x < 1/4 \}
$$
and which we know (from standard calculus books like Spivak) to be connected. 
Now look at the function 
$$
S : K \to H : (x, y) \mapsto (x-1, y - G_1(x))
$$
This is clearly continuous and a bijection (and even extends to a bijection from a (vertical) neighborhood of $K$ to a neighborhood of $H$), so $K$ is also connected. 
End of digression
And then for numbers with finite base-2-expansions, you can do the same sort of thing: let
$$
G(x) = \sum_{k \in \Bbb Z, k > 0} \frac{1}{2^k} F(2^k x)
$$
and that'll have $f$-like discontinuities at all the points with finite base-2 representations, which is a dense set in $\Bbb R$. 
But I have a feeling that sliding over to the uncountable-set territory is going to be a lot harder. 
