five

I am trying to fix the blue region in the figure below but the white part is not completely filled yet.

 enter image description here

Here are the following Latex codes for the standalone figure:

 \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{backgrounds,intersections} \usepackage{amsmath} \begin{document} \begin{tikzpicture} % Draw the axes \draw[thin,-] (0,0) -- (4.5,0) node[anchor=north west] {$\psi \gamma_{c}$}; \draw[thin,-] (0,0) -- (0,4.5) node[anchor=south east] {$\phi \gamma_{e}$}; % Define colors \fill[red,opacity=0.3] (0,0) -- (3.18,3.18) -- (4.5,4.5) -- (0,4.5) -- cycle; \fill[blue,opacity=0.3] (0,0) -- (3.18,3.18) -- (5,0) -- cycle; % Draw the diagonal line and annotations \draw (0,0) -- (45:6.2)  node[pos=0.86, above left]{\text{Cash regime}} node[pos=0.55,above left] {$ \begin{aligned} \tau_{x} &= 0 \\ (\phi \gamma_{e} &\geq \psi \gamma_{c}) \end{aligned} $} node[right]{$\zeta = \frac{\gamma_{e}}{\gamma_{c}} = 1$} node[pos=0.30, below right]{\text{CBDC regime}} node[pos=0.55,right] {$ \begin{aligned} \tau_{x} &>0 \\ (\phi \gamma_{e} &< \psi \gamma_{c}) \\ \end{aligned} $} ; \end{tikzpicture}% \end{document}

Any help would be appreciated.

one
  • How did you choose the co-ordinate (3.18,3.18) in the fill regions here? It seems entirely random — nothing to do with the rest of the graph. May 20 at 14:31

2 Answers two

Reset to default
six

Although it is not terribly visible in the particular example chosen here, it is generally better to fill first and draw afterwards. If you draw the area first and then fill it, the drawn lines will be partly obscured by the fill. Either draw and fill together or draw later.

To see the difference, change the opacities of the fills to one .

This also demonstrates the use of named coordinates to make things more flexible. This also makes it easier to fill the lower blue part.

 \documentclass{standalone} \usepackage{tikz} \usepackage{amsmath} \begin{document} \begin{tikzpicture} % Draw the axes \draw[thin,-] (0,0) coordinate (O)  -- (4.5,0) coordinate (C) node[anchor=north west]  {$\psi \gamma_{c}$}; \draw[thin,-] (O) -- (0,4.5) coordinate (E) node[anchor=south east]  {$\phi \gamma_{e}$}; % Define colors \fill[red!30]   (O) -- (3.18,3.18) coordinate (A) -- (4.5,4.5) coordinate (B) --  (E) -- cycle; \fill[blue!30] (O) -- (B) -- (B |- O) -- cycle; %    Draw the diagonal line and annotations \draw (O) -- (45:6.2)  node[pos=0.86, above left]{\text{Cash regime}} node[pos=0.55,above left] {$ \begin{aligned} \tau_{x} &= 0 \\ (\phi \gamma_{e} &\geq \psi \gamma_{c}) \end{aligned} $} node[right]{$\zeta = \frac{\gamma_{e}}{\gamma_{c}} = 1$} node[pos=0.30, below right]{\text{CBDC regime}} node[pos=0.55,right] {$ \begin{aligned} \tau_{x} &>0 \\ (\phi \gamma_{e} &< \psi \gamma_{c}) \\ \end{aligned} $} ; \end{tikzpicture}% \begin{tikzpicture} % Define colors \fill[red!30] (0,0) coordinate  (O) -- (3.18,3.18) coordinate (A) -- (4.5,4.5) coordinate (B) -- (0,4.5) coordinate (E) -- cycle; \fill[blue!30] (O) -- (B) -- (B |- O) -- cycle; % Draw the axes \draw[thin,-] (O)  -- (4.5,0) coordinate (C) node[anchor=north west]  {$\psi \gamma_{c}$}; \draw[thin,-] (O) -- (E) node[anchor=south east]  {$\phi \gamma_{e}$}; % Draw the diagonal line and annotations \draw (O) -- (45:6.2)  node[pos=0.86, above left]{\text{Cash regime}} node[pos=0.55,above left] {$ \begin{aligned} \tau_{x} &= 0 \\ (\phi \gamma_{e} &\geq \psi \gamma_{c}) \end{aligned} $} node[right]{$\zeta = \frac{\gamma_{e}}{\gamma_{c}} = 1$} node[pos=0.30, below right]{\text{CBDC regime}} node[pos=0.55,right] {$ \begin{aligned} \tau_{x} &>0 \\ (\phi \gamma_{e} &< \psi \gamma_{c}) \\ \end{aligned} $} ; \end{tikzpicture}% \end{document}

Here goes nothing (my images suck right now):

 comparison of drawing and filling order with opacity=1

three

My solution and other answers are welcome! Just extended the diagonal and played with the colors.

 \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{backgrounds,intersections} \usepackage{amsmath} \begin{document} \begin{tikzpicture} % Draw the axes \draw[thin,-] (0,0) -- (4.5,0) node[anchor=north west] {$\psi \gamma_{c}$}; \draw[thin,-] (0,0) -- (0,4.5) node[anchor=south east] {$\phi \gamma_{e}$}; % Define colors \fill[red,opacity=0.3] (0,0) -- (4.5,4.5) -- (0,4.5) -- cycle; \fill[blue,opacity=0.3] (0,0) -- (4.5,4.5) -- (4.5,0) -- cycle; % Draw the diagonal line and annotations \draw (0,0) -- (45:6.35)  node[pos=0.75, above left]{\text{Cash regime}} node[pos=0.50,above left] {$ \begin{aligned} \tau_{x} &= 0 \\ (\phi \gamma_{e} &\geq \psi \gamma_{c}) \end{aligned} $} node[right]{$\zeta = \frac{\gamma_{e}}{\gamma_{c}} = 1$} node[pos=0.25, below right]{\text{CBDC regime}} node[pos=0.50,right] {$ \begin{aligned} \tau_{x} &>0 \\ (\phi \gamma_{e} &< \psi \gamma_{c}) \\ \end{aligned} $} ; \end{tikzpicture}% \end{document}

 enter image description here

two
  • two
    Why not go to the end of the diagonal and write \draw (0,0) -- (4.5,4.5) instead of \draw (0,0) -- (45:6.35) ?
    –  AndréC
    May 19 at 10:48
  • So is this the intended result? It wasn't clear to me from the question.
    –  cfr
    May 19 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .