Does a closed point of a scheme have an affine open environment with the same dimension? Consider a scheme $X$, and an a closed point $x\in X$. I am wondering whether there is an affine open neighborhood $x\in U\subseteq X$ such that 
$$\dim \mathcal O_{X,x}=\dim U.$$

I tried the following approach: Let $V=\mathrm{spec}(R)$, then $\mathcal O_{X,x}=R_{\mathfrak m_x}$, where $\mathfrak m_x$ is the maximal ideal corresponding to the closed point $x$. Let $f\in R$ with $f\notin \mathfrak m_x$, then $U=\mathrm{spec}(R_f)$ is an open subset of $V$ that contains $x$. As every chain of prime ideals in $R_{\mathfrak m_x}$ is a chain in $R_f$ as well, we have $\dim\mathcal O_{X,x}\leq \dim U$. Unfortunately, I do not understand if we can choose an $f$ for which we obtain equality.

If this is not possible in general, can we prove it for a variety, i.e. an integral, separated scheme of finite type over $\mathbb C$?
The answer to your first question is no.

Let $k$ be a field and $m_i$ a sequence of positive integers such that $m_{i+1}-m_i &gt;m_i-m_{i-1}$. For each positive integer $i$, let $\mathfrak{p}_i=(x_{m_i+1},\dots,x_{m_{i+1}})$, which is a prime ideal of $B=k\left[x_1,\dots,x_n,\dots\right]$. Let $S$ be the union of the $\mathfrak{p}_i$'s and $A$ the localization of $B$ at $S$ (the ring $B$ has been introduced by Nagata). Then, the $S^{-1}\mathfrak{p}_i$'s are maximal ideals of $A$ (see Remark 1 of Tomo's answer in this MSE question).

Now, let $X=\text{Spec}(A)$ and chose $x=S^{-1}\mathfrak{p}_i$ a closed point of $X$: note that $\dim\mathscr{O}_{X,x}=\text{ht}(S^{-1}\mathfrak{p}_i)=m_{i+1}-m_i$. Now let $D(f)$ be a principal open set containing $x$ for some $f\in A$. One may assume that $f$ comes from an element $g$ of $B$ (take $g$ to be the numerator of a representative of $f$) and let $l&gt;i+1$ such that $l$ is greater than all the indices of the indeterminates occurring in $f$: then, for any $j\geq l$, you may check that $S^{-1}\mathfrak{p}_j\in D(f)$ (this comes from the choice of $l$: none of the $x_n$'s occur in $f$ for $n\geq l$). This shows that $\dim D(f)=\infty&gt;\dim\mathscr{O}_{X,x}$.



Nonetheless, the answer is positive for schemes locally of finite type over a field.

Indeed, if $X$ is locally of finite type over a field $k$, then one may show that for any point $x\in X$ one has that $$\dim_xX=\dim\mathscr{O}_{X,x}+\text{degtr}(\kappa(x)/k)$$ (where $\dim_xX=\min_{U\ni x}\dim U$). When $x$ is closed, one gets that $\dim_xX=\dim\mathscr{O}_{X,x}$ which answers your question.
The answer to your first question is no.

Let $k$ be a field and $m_i$ a sequence of positive integers such that $m_{i+1}-m_i &gt;m_i-m_{i-1}$. For each positive integer $i$, let $\mathfrak{p}_i=(x_{m_i+1},\dots,x_{m_{i+1}})$, which is a prime ideal of $B=k\left[x_1,\dots,x_n,\dots\right]$. Let $S$ be the union of the $\mathfrak{p}_i$'s and $A$ the localization of $B$ at $S$ (the ring $B$ has been introduced by Nagata). Then, the $S^{-1}\mathfrak{p}_i$'s are maximal ideals of $A$ (see Remark 1 of Tomo's answer in this MSE question).

Now, let $X=\text{Spec}(A)$ and chose $x=S^{-1}\mathfrak{p}_i$ a closed point of $X$: note that $\dim\mathscr{O}_{X,x}=\text{ht}(S^{-1}\mathfrak{p}_i)=m_{i+1}-m_i$. Now let $D(f)$ be a principal open set containing $x$ for some $f\in A$. One may assume that $f$ comes from an element $g$ of $B$ (take $g$ to be the numerator of a representative of $f$) and let $l&gt;i+1$ such that $l$ is greater than all the indices of the indeterminates occurring in $f$: then, for any $j\geq l$, you may check that $S^{-1}\mathfrak{p}_j\in D(f)$ (this comes from the choice of $l$: none of the $x_n$'s occur in $f$ for $n\geq l$). This shows that $\dim D(f)=\infty&gt;\dim\mathscr{O}_{X,x}$.



Nonetheless, the answer is positive for schemes locally of finite type over a field.

Indeed, if $X$ is locally of finite type over a field $k$, then one may show that for any point $x\in X$ one has that $$\dim_xX=\dim\mathscr{O}_{X,x}+\text{degtr}(\kappa(x)/k)$$ (where $\dim_xX=\min_{U\ni x}\dim U$). When $x$ is closed, one gets that $\dim_xX=\dim\mathscr{O}_{X,x}$ which answers your question.