\pgfplotsset{compat=1.14} 

\newcommand{\tvalue}{1.0} 

% Define the parameter s
% Constraints: 0 < s < 1 and s < t < 2-s
\newcommand{\svalue}{0.6}

% Calculate intersection point for semi-well-spaced case lines
\pgfmathsetmacro{\xi}{(\tvalue - \svalue) / (2*(1-\svalue))}
\pgfmathsetmacro{\yi}{(2-\svalue)*\xi}


\begin{tikzpicture}
    \begin{axis}[
        xlabel={$\log_\delta \rho$},
        ylabel={$\log_{\frac{1}{\delta}}|E_\rho|$},
        ylabel style={sloped like x axis}, 
        xmin=0, xmax=1,                  
        ymin=0, ymax={\tvalue},          
        xtick={0, 1},                    
        ytick={0, \tvalue},              
        yticklabels={$0$, $t$},          
        axis lines=left,                 
        width=0.75\textwidth,            
        height=0.45\textwidth,           
        clip=false,                      
    ]

    
    % The region is a triangle with vertices (0,0), (t/2, t), and (1,t)
    \addplot[
        fill=myred,
        fill opacity=0.1, 
        draw=none 
    ] coordinates {(0,0) (\tvalue/2, \tvalue) (1, \tvalue) (0,0)};

    % Dashed line from (0,0) to (1,t)
    \addplot[
        dashed,
        color=myblack!30,
        thick
    ] coordinates {(0,0) (1,\tvalue)}
        node[pos=0.5, sloped, below, font=\small, text=black]
            {AD-regular case, slope $= t$}; 

    % Dashed Line from (0,0) to (t/2,t)
    \addplot[
        dashed,
        color=myblack!30,
        thick
    ] coordinates {(0,0) (\tvalue/2, \tvalue)}
        node[pos=0.6, sloped, above, font=\small, text=black, inner sep=2pt]
            {Well-spaced case, slope $= 2$}; 

    % Dashed Line from (t/2,t) to (1,t)
    \addplot[
        dashed,
        color=myblack!30,
        thick
    ] coordinates {(\tvalue/2, \tvalue) (1, \tvalue)};

    % Semi-well-spaced case lines
    % Line from (0,0) to (xi, yi) with slope (2-s)
    \addplot[
        dashed,
        color=mygreen,
        thick
    ] coordinates {(0,0) (\xi, \yi)};
    % Line from (xi, yi) to (1,t) with slope s
    \addplot[
        dashed,
        color=mygreen,
        thick
    ] coordinates {(\xi, \yi) (1, \tvalue)};

    % Plot the main function
    \addplot[
        domain=0:1,       
        samples=100,      
        smooth,           
        color=myblue,       
        thick,
        z=-1 
    ] {(\tvalue)*x + (\tvalue)*x*(1-x)}; % The function

    \end{axis}
\end{tikzpicture}
