Элегантные хэш-области для математической графики...

Элегантные хэш-области для математической графики...

Иногда на графике нужно хешировать области, чтобы наглядно показать, что такое домены. Есть ли элегантный способ создания этих хешированных областей с помощью инструкции, похожей на прямоугольную? Можно ли хешировать внутреннюю часть любой фигуры? И было бы здорово, если бы хеш автоматически допускал пробелы, когда требуется наложение обозначений (например, для x и 1 в моем MWE)... Я знаю о шаблоне=линии северо-востока, но он слишком жесткий, я не могу контролировать расстояние между линиями. Мой MWE немного многословен, извините...

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows}

\begin{document}

\resizebox{7.0cm}{!}{
\begin{tikzpicture}[>=triangle 45]% functia PUTERE 2^x
%\clip (-0.5,-0.5) rectangle (4.0,4.0);
% grid
%\draw[step = 0.1cm, gray, ultra thin] (-5.0, -1.0) grid (4.0, 0.0);
%
% HASH lines for y < 0
%
\draw[red, line width=1.00pt] (-5.0, -0.1) -- (-4.9, 0.0);
\draw[red, line width=1.00pt] (-5.0, -0.5) -- (-4.5, 0.0);
\draw[red, line width=1.00pt] (-5.0, -1.0) -- (-4.0, 0.0);
\draw[red, line width=1.00pt] (-4.5, -1.0) -- (-3.5, 0.0);
\draw[red, line width=1.00pt] (-4.0, -1.0) -- (-3.0, 0.0);
\draw[red, line width=1.00pt] (-3.5, -1.0) -- (-2.5, 0.0);
\draw[red, line width=1.00pt] (-3.0, -1.0) -- (-2.0, 0.0);
\draw[red, line width=1.00pt] (-2.5, -1.0) -- (-1.5, 0.0);
\draw[red, line width=1.00pt] (-2.0, -1.0) -- (-1.0, 0.0);
\draw[red, line width=1.00pt] (-1.5, -1.0) -- (-0.5, 0.0);
\draw[red, line width=1.00pt] (-1.0, -1.0) -- (0.0, 0.0);
\draw[red, line width=1.00pt] (-0.5, -1.0) -- (0.5, 0.0);
% gap for x notation
\draw[red, line width=1.00pt] (0.0, -1.0) -- (0.4, -0.6);
\draw[red, line width=1.00pt] (0.7, -0.3) -- (1.0, 0.0);
%
\draw[red, line width=1.00pt] (0.5, -1.0) -- (1.5, 0.0);
\draw[red, line width=1.00pt] (1.0, -1.0) -- (2.0, 0.0);
\draw[red, line width=1.00pt] (1.5, -1.0) -- (2.5, 0.0);
\draw[red, line width=1.00pt] (2.0, -1.0) -- (3.0, 0.0);
\draw[red, line width=1.00pt] (2.5, -1.0) -- (3.5, 0.0);
\draw[red, line width=1.00pt] (3.0, -1.0) -- (4.0, 0.0);
\draw[red, line width=1.00pt] (3.5, -1.0) -- (4.0, -0.5);
\draw[red, line width=1.00pt] (3.9, -1.0) -- (4.0, -0.9);
%
% 
\coordinate (OR) at (0.00, 0.00);
\coordinate (LX) at (-5.00, 0.00); % left x
\coordinate (RX) at (4.00, 0.00); % right x
\coordinate (BY) at (0.00, -1.00); % bottom y
\coordinate (TY) at (0.00, 8.00);
%
% axa 0x
%
\draw[->][line width=1.00pt] (LX) -- (RX);
\node[violet] at (3.8,-0.4) {\textbf{\textit{x}}};
%
% axa 0y
%
\draw[->][line width=1.00pt] (BY) -- (TY);
\node[right,violet] at (0.2, 8.0) {{\boldmath$a^{\raisebox{+4.0pt}{$\scriptstyle{x}$}}$}};
\node[right,violet] at (0.1, 7.3) {{\boldmath$(a \,=\, 2)$}};
%
% ORIGINE
% points on the graphic
\filldraw [red] (OR) circle(2pt);
\node[violet] at (-0.2,-0.3) {\textbf{\textit{0}}};
%
% COORDONATE -- numerotare axa Ox POZITIVA
%
\draw[violet,line width=1pt] (0.50, -0.10) -- (0.50, 0.10); % x = 0.5
\node[violet] at (0.50, -0.40) {\textbf{\textit{x}}}; 
\draw[violet,line width=0.75pt,dotted] (0.50, 0.00) -- (0.50, 1.4142);
\filldraw [violet] (0.50, 1.4142) circle(2pt);
\node[above,violet] at (0.50, 1.4142) {\textbf{\textit{a\textsuperscript{x}}}}; 
%
\draw[line width=1pt] (1.00, -0.10) -- (1.00, 0.10); % x1
\node at (1.00, -0.40) {$\scriptstyle{1}$};
\draw[line width=1pt] (2.00, -0.10) -- (2.00, 0.10); % x2
\node at (2.00, -0.40) {$\scriptstyle{2}$};
\draw[line width=1pt] (3.00, -0.10) -- (3.00, 0.10); % x3
\node at (3.00, -0.40) {$\scriptstyle{3}$};
%
% COORDONATE -- numerotare axa Ox NEGATIVA
%
\draw[line width=1pt] (-1.00, -0.10) -- (-1.00, 0.10); % -x1
\node at (-1.10, -0.40) {$\scriptstyle{-1}$};
\draw[line width=1pt] (-2.00, -0.10) -- (-2.00, 0.10); % -x2
\node at (-2.10, -0.40) {$\scriptstyle{-2}$};
\draw[line width=1pt] (-3.00, -0.10) -- (-3.00, 0.10); % -x3
\node at (-3.10, -0.40) {$\scriptstyle{-3}$};
\draw[line width=1pt] (-4.00, -0.10) -- (-4.00, 0.10); % -x4
\node at (-4.10, -0.40) {$\scriptstyle{-4}$};
%
%
% COORDONATE -- numerotare axa Oy POZITIVA
%
\draw[line width=1.00pt] (-0.1, 1.00) -- (0.10, 1.00); % y1 
\node at (-0.40, 1.00) {$\scriptstyle{1}$};
\draw[line width=1.00pt] (-0.1, 2.00) -- (0.10, 2.00); % y2 
\node at (-0.40, 2.00) {$\scriptstyle{2}$};
\draw[line width=1.00pt] (-0.1, 3.00) -- (0.10, 3.00); % y3
\node at (-0.40, 3.00) {$\scriptstyle{3}$};
\draw[line width=1.00pt] (-0.1, 4.00) -- (0.10, 4.00); % y4 
\node at (-0.40, 4.00) {$\scriptstyle{4}$};
\draw[line width=1.00pt] (-0.1, 5.00) -- (0.10, 5.00); % y5 
\node at (-0.40, 5.00) {$\scriptstyle{5}$};
\draw[line width=1.00pt] (-0.1, 6.00) -- (0.10, 6.00); % y6 
\node at (-0.40, 6.00) {$\scriptstyle{6}$};
\draw[line width=1.00pt] (-0.1, 7.00) -- (0.10, 7.00); % y7 
\node at (-0.40, 7.00) {$\scriptstyle{7}$};
%
% COORDONATE -- numerotare axa Oy NEGATIVA
%
% GRAFICUL functiei 2^x
%
\draw[violet, line width=1.75pt, domain=-5.00:3.00] plot[smooth](\x, {2^(\x)});
%
% filled circles
%
\filldraw [blue] (0.0,1.0) circle(2pt);
%
\end{tikzpicture}
}
%
\hspace*{1.0cm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\resizebox{8.0cm}{!}{
\begin{tikzpicture}[>=triangle 45]%functia LOGARITM ln x
% grid
%\draw[step = 0.1cm, gray, ultra thin] (-1.0, 0.0) grid (0.0, 2.0);
%
% HASH lines for x < 0
%
\draw[red, line width=1.00pt] (-1.0, 2.9) -- (-0.9, 3.0);
\draw[red, line width=1.00pt] (-1.0, 2.5) -- (-0.5, 3.0);
\draw[red, line width=1.00pt] (-1.0, 2.0) -- (0.0, 3.0);
\draw[red, line width=1.00pt] (-1.0, 1.5) -- (0.0, 2.5);
\draw[red, line width=1.00pt] (-1.0, 1.0) -- (0.0, 2.0);
% gap for 1
\draw[red, line width=1.00pt] (-1.0, 0.5) -- (-0.5, 1.0);
\draw[red, line width=1.00pt] (-0.3, 1.2) -- (0.0, 1.5);
%
\draw[red, line width=1.00pt] (-1.0, 0.0) -- (0.0, 1.0);
\draw[red, line width=1.00pt] (-1.0, -0.5) -- (0.0, 0.5);
\draw[red, line width=1.00pt] (-1.0, -1.0) -- (0.0, 0.0);
\draw[red, line width=1.00pt] (-1.0, -1.5) -- (0.0, -0.5);
\draw[red, line width=1.00pt] (-1.0, -2.0) -- (0.0, -1.0);
\draw[red, line width=1.00pt] (-1.0, -2.5) -- (0.0, -1.5);
\draw[red, line width=1.00pt] (-1.0, -3.0) -- (0.0, -2.0);
\draw[red, line width=1.00pt] (-1.0, -3.5) -- (0.0, -2.5);
\draw[red, line width=1.00pt] (-1.0, -4.0) -- (0.0, -3.0);
\draw[red, line width=1.00pt] (-1.0, -4.5) -- (0.0, -3.5);
\draw[red, line width=1.00pt] (-1.0, -5.0) -- (0.0, -4.0);
\draw[red, line width=1.00pt] (-1.0, -4.5) -- (0.0, -3.5);
\draw[red, line width=1.00pt] (-1.0, -5.0) -- (0.0, -4.0);
\draw[red, line width=1.00pt] (-0.5, -5.0) -- (0.0, -4.5);
\draw[red, line width=1.00pt] (-0.1, -5.0) -- (0.0, -4.9);
%
% LOGARITM function
%
%\clip (-0.5,-0.5) rectangle (4.0,4.0);
%
% grid, drawn with a step in a specified rectangle
%\draw[step = 0.1cm, gray, ultra thin] (-1.0, -5.0) grid (0.0,3.0);
%
%\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
%
%
%\begin{comment}
% 
\coordinate (OR) at (0.00, 0.00);
\coordinate (LX) at (-1.00, 0.00);
\coordinate (RX) at (8.00, 0.00);
\coordinate (BY) at (0.00, -5.00);
\coordinate (TY) at (0.00, 3.00);
%
% axa 0x
%
\draw[->][line width=1.00pt] (LX) -- (RX);
\node[blue] at (7.8,-0.4) {\textbf{\textit{x}}};
%
% axa 0y
%
\draw[->][line width=1.00pt] (BY) -- (TY);
\node[right,blue] at (0.2, 2.8) {\textbf{\textit{ln x}}};
%
% ORIGIN
% points on the graphic
\filldraw [red] (OR) circle(2pt);
\node[red] at (0.2,-0.3) {\textbf{\textit{0}}};
%
% COORDONATE -- numerotare axa Ox POZITIVA
%
\draw[line width=1pt] (1.00, -0.10) -- (1.00, 0.10); % x1
\node at (1.00, -0.40) {$\scriptstyle{1}$};
\draw[line width=1pt] (2.00, -0.10) -- (2.00, 0.10); % x2
\node at (2.00, -0.40) {$\scriptstyle{2}$};
\draw[line width=1pt] (3.00, -0.10) -- (3.00, 0.10); % x3
\node at (3.00, -0.40) {$\scriptstyle{3}$};
\draw[line width=1pt] (4.00, -0.10) -- (4.00, 0.10); % x4
\node at (4.00, -0.40) {$\scriptstyle{4}$};
\draw[line width=1pt] (5.00, -0.10) -- (5.00, 0.10); % x5
\node at (5.00, -0.40) {$\scriptstyle{5}$};
\draw[line width=1pt] (6.00, -0.10) -- (6.00, 0.10); % x6
\node at (6.00, -0.40) {$\scriptstyle{6}$};
\draw[line width=1pt] (7.00, -0.10) -- (7.00, 0.10); % x7
\node at (7.00, -0.40) {$\scriptstyle{7}$};
%
% COORDONATE -- numerotare axa Ox NEGATIVA
%
% COORDONATE -- numerotare axa Oy POZITIVA
%
\draw[magenta, line width=1.00pt] (-0.1, 1.00) -- (0.10, 1.00); % y1 
\node[magenta] at (-0.40, 1.00) {$1$};
\draw[line width=1.00pt] (-0.1, 2.00) -- (0.10, 2.00); % y2 
\node at (-0.40, 2.00) {$\scriptstyle{2}$};
%
% COORDONATE -- numerotare axa Oy NEGATIVA
%
\draw[line width=1.00pt] (-0.1, -1.00) -- (0.10, -1.00); % y1 
\node at (-0.40, -1.00) {$\scriptstyle{-1}$};
\draw[line width=1.00pt] (-0.1, -2.00) -- (0.10, -2.00); % y2 
\node at (-0.40, -2.00) {$\scriptstyle{-2}$};
\draw[line width=1.00pt] (-0.1, -3.00) -- (0.10, -3.00); % y3
\node at (-0.40, -3.00) {$\scriptstyle{-3}$};
\draw[line width=1.00pt] (-0.1, -4.00) -- (0.10, -4.00); % y4 
\node at (-0.40, -4.00) {$\scriptstyle{-4}$};
\draw[line width=1.00pt] (-0.1, -5.00) -- (0.10, -5.00); % y5 
\node at (-0.40, -5.00) {$\scriptstyle{-5}$};
%
% COORDINATES for drawing
%
%
\coordinate (EE) at (2.7182, 0.00);
\coordinate (PI) at (3.1415, 0.00);
%
% GRAFICUL functiei LOGARITM
%
\draw[blue, line width=1.75pt, domain=0.01:7.00, samples=500] plot[smooth](\x, {ln(\x)});
%
% filled circles
%
\filldraw [red] (1.00, 0.00) circle(2pt);
%
% punctul e
%
\filldraw [magenta] (EE) circle(2pt);
\node[magenta] at (2.7182, -0.30) {\textbf{\textit{e}}};
\draw[magenta, dotted, line width=1.00pt] (2.7182, 0.00) -- (2.7182, 1.00); % e
\draw[magenta, dotted, line width=1.00pt] (0.00, 1.00) -- (2.7182, 1.00); % e
\filldraw [magenta] (2.7182, 1.00) circle(2pt);
%
\end{tikzpicture}
}

\end{document}

решение1

Следующий код показывает, как использовать определение a patternс определенным пользователем \hatchthicknessи \hatchdistance. Этот шаблон был взят изиспользование узора внутри фигур тикз с падающими тенями

Этот узор используется для fillпрямоугольного узла, который рисуется в фоновом слое:

\begin{scope}[on background layer]
\node[fit={(-5,0) (4,-1)}, inner sep=0pt, Pattern] {};
\end{scope}

Шаблон не учитывает holes, но вы можете разместить fill=whiteнад ним все узлы, которые должны быть читаемы:

\node[violet,fill=white] at (3.8,-0.4) {\textbf{\textit{x}}};

Ваш код был сокращен с помощью определения шаблона, но также с использованием некоторых \foreachциклов для рисования ticks. И я думаю, что он мог бы быть сокращен еще больше, если бы вы использовали, pgfplotsкоторый загружен, но никогда не используется.

Следующий код показывает только левую фигуру. Правую можно легко получить, используя аналогичные инструменты.

\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows,patterns,backgrounds,fit}

\makeatletter
\tikzset{% customization of pattern
         % based on <m.wibrow@gm...> - 2013-03-24 07:20: 
        hatch distance/.store in=\hatchdistance,
        hatch distance=5pt,
        hatch thickness/.store in=\hatchthickness,
        hatch thickness=5pt
        }
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north east hatch}% name
    {\pgfqpoint{-1pt}{-1pt}}% below left
    {\pgfqpoint{\hatchdistance}{\hatchdistance}}% above right
    {\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
    {
        \pgfsetcolor{\tikz@pattern@color}
        \pgfsetlinewidth{\hatchthickness}
        \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
        \pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
        \pgfusepath{stroke}
    }
\makeatother

\tikzset{Pattern/.style={pattern=north east hatch, 
         pattern color=red, hatch distance=3mm, 
         hatch thickness=1pt}}

\begin{document}

%\resizebox{7.0cm}{!}{
\begin{tikzpicture}[>=triangle 45]% functia PUTERE 2^x
%\clip (-0.5,-0.5) rectangle (4.0,4.0);
% grid
%\draw[step = 0.1cm, gray, ultra thin] (-5.0, -1.0) grid (4.0, 0.0);

%
% 
\coordinate (OR) at (0.00, 0.00);
\coordinate (LX) at (-5.00, 0.00); % left x
\coordinate (RX) at (4.00, 0.00); % right x
\coordinate (BY) at (0.00, -1.00); % bottom y
\coordinate (TY) at (0.00, 8.00);
%
% axa 0x
%
\draw[->][line width=1.00pt] (LX) -- (RX);
\node[violet,fill=white] at (3.8,-0.4) {\textbf{\textit{x}}};
%
% axa 0y
%
\draw[->][line width=1.00pt] (BY) -- (TY);
\node[right,violet] at (0.2, 8.0) {{\boldmath$a^{\raisebox{+4.0pt}{$\scriptstyle{x}$}}$}};
\node[right,violet] at (0.1, 7.3) {{\boldmath$(a \,=\, 2)$}};
%
% ORIGINE
% points on the graphic
\filldraw [red] (OR) circle(2pt);
\node[violet,fill=white] at (-0.2,-0.3) {\textbf{\textit{0}}};
%
% COORDONATE -- numerotare axa Ox POZITIVA
%
\draw[violet,line width=1pt] (0.50, -0.10) -- (0.50, 0.10); % x = 0.5
\node[violet,fill=white] at (0.50, -0.40) {\textbf{\textit{x}}}; 
\draw[violet,line width=0.75pt,dotted] (0.50, 0.00) -- (0.50, 1.4142);
\filldraw [violet] (0.50, 1.4142) circle(2pt);
\node[above,violet] at (0.50, 1.4142) {\textbf{\textit{a\textsuperscript{x}}}}; 
%

\foreach \i in {-4,...,-1,1,2,3}{
 \draw[line width=1pt] (1.00*\i, -0.10) -- ++(90:0.20); % x1
 \node[fill=white] at (1.00*\i, -0.40) {$\scriptstyle{\i}$};}

%
% COORDONATE -- numerotare axa Oy POZITIVA
%
\foreach \i in {1,...,7}{
    \draw[line width=1.00pt] (-0.1, \i) -- ++(0:0.20); % y1 
    \node at (-0.40, \i) {$\scriptstyle{\i}$};
    }
%
% COORDONATE -- numerotare axa Oy NEGATIVA
%
% GRAFICUL functiei 2^x
%
\draw[violet, line width=1.75pt, domain=-5.00:3.00] plot[smooth](\x, {2^(\x)});
%
% filled circles
%
\filldraw [blue] (0.0,1.0) circle(2pt);
%
\begin{scope}[on background layer]
\node[fit={(-5,0) (4,-1)}, inner sep=0pt, Pattern] {};
\end{scope}

\end{tikzpicture}

введите описание изображения здесь

Обновлять

Спасибо Гонсало Медине, у нас есть pgfplotsверсия этой фигурки:

\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows,patterns,backgrounds,fit}

\makeatletter
\tikzset{% customization of pattern
         % based on <m.wibrow@gm...> - 2013-03-24 07:20:
        hatch distance/.store in=\hatchdistance,
        hatch distance=5pt,
        hatch thickness/.store in=\hatchthickness,
        hatch thickness=5pt
        }
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north east hatch}% name
    {\pgfqpoint{-1pt}{-1pt}}% below left
    {\pgfqpoint{\hatchdistance}{\hatchdistance}}% above right
    {\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
    {
        \pgfsetcolor{\tikz@pattern@color}
        \pgfsetlinewidth{\hatchthickness}
        \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
        \pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
        \pgfusepath{stroke}
    }
\makeatother

\tikzset{Pattern/.style={pattern=north east hatch,
         pattern color=#1, hatch distance=3mm,
         hatch thickness=1pt}}

\begin{document}

\begin{tikzpicture}[>=triangle 45]
\begin{axis}[
  axis lines=middle,
  ymax=8,
  ymin=-1,
  xmax=3.5,
  clip=false,
  xtick={-4,-3,...,3},
  ytick={1,2,...,8},
  x tick label style={fill=white}
  ]
\addplot[violet, line width=1.75pt, domain=-5.00:3.00] {2^(x)};

\node[violet,fill=white]
  at (axis cs:3.8,-0.4) {\textbf{\textit{x}}};
\node[right,violet]
  at (axis cs:0.2, 8.0)
  {{\boldmath$a^{x}$}};
\node[right,violet]
  at (axis cs:0.1, 7.3) {{\boldmath$(a \,=\, 2)$}};
\filldraw[red] (axis cs:0,0) circle(2pt);
\draw[violet,line width=0.75pt,dotted]
  (axis cs:0.50, 0.00) -- (axis cs:0.50, 1.4142);
\filldraw[violet] (axis cs:0.50, 1.4142) circle(2pt)
  node[above,violet]
    at (axis cs:0.50, 1.4142)
    {\textbf{\textit{a\textsuperscript{x}}}};
\filldraw[blue] (axis cs:0.0,1.0) circle(2pt);

\begin{scope}[on background layer]
\node[fit={(axis cs:-5,0) (axis cs:3.5,-1.3)}, inner sep=0pt, Pattern=cyan] {};
\end{scope}
\end{axis}
\end{tikzpicture}

\end{document}

который производит:

введите описание изображения здесь

решение2

Я позволил себе нарисовать один из примеров с mfpicпакетом, который поставляется с макросом, специально созданным для решения подобных задач:

\thatch[<hatchsp>,<angle>][<color>]<closed path> 

Он заполняет любой замкнутый контур линиями в <angle>градусах, отделенными друг от друга расстоянием hatchsp. Другой макрос, \hatchwd{}макрос задает ширину этих линий. Также есть два других макроса штриховки как варианты с \thatchпредопределенными углами, \rhatch(идущие из нижнего левого угла в верхний правый) и \lhatch(идущие из нижнего правого угла в верхний левый).

В этом примере все работы по штриховке выполняются по следующим инструкциям:

\hatchwd{1pt}
\rhatch[3mm][Cyan]\rect{(\xmin, \ymin), (\xmax, 0)}

Полный код:

\documentclass{scrartcl}
\usepackage{multido, xcolor}
\usepackage[metapost, clip, overlaylabels]{mfpic}
    \setlength{\mfpicunit}{1cm}
    \opengraphsfile{\jobname}
\begin{document}
\begin{mfpic}[1]{-7}{3.9}{-1.5}{8.9}
    % Function
    \penwd{1pt}
    \fdef{f}{x}{2**x}
   \draw[magenta]\function{\xmin, \xmax, 0.05}{f(x)}    
   % Hatching
   \hatchwd{1pt}
   \rhatch[3mm][Cyan]\rect{(\xmin, \ymin), (\xmax, 0)}
   % Axes and marks
   \penwd{.5pt}
   \doaxes{xy}
   \xmarks{ceiling(\xmin) upto -1}\xmarks{1 upto floor(\xmax)}
   \ymarks{ceiling(\ymin) upto -1}\ymarks{2 upto floor(\ymax)}
   \pointcolor{red}\point[4pt]{(0, 0)}
   \pointcolor{blue}\point[4pt]{(0, 1)}
   % Labels
   \setrender{\gclear}
   \tlpointsep{3pt}
    \tlabelrect[][tr](0, 0){$O$} 
    \tlabelrect[][tc](\xmax, 0){$x$} 
    \tlabel[cr](0, \ymax){$y$}
    \tlpointsep{6pt}
    \tlpathsep{1pt}
    \multido{\i=\xmin+1}{-\xmin}{\tlabelrect[][tc](\i, 0){$\i$}}
    \multido{\i=1+1}{\xmax}{\tlabelrect[][tc](\i, 0){$\i$}}
    \multido{\i=1+1}{\ymax}{\tlabel[cr](0, \i){$\i$}}
    \tlabelrect[][cr](0, -1){$-1$}
    \drawcolor{magenta}
    \dashed\lines{(0.5, 0), (0.5, 1.414)}
    \tlabel[cr](3, 8){\textcolor{magenta}{$a^x (a=2)$}}
    \tlabel[bc](0.5, 1.414){\textcolor{magenta}{$a^x$}}
    \tlabelrect[][tc](0.5, 0){\textcolor{magenta}{$x$}}
\end{mfpic}
\closegraphsfile
\end{document}

Сначала файл должен быть скомпилирован с помощью LaTeX (независимо от движка), затем полученный .mpфайл с помощью MetaPost, а затем .texфайл снова с помощью LaTeX.

введите описание изображения здесь

Связанный контент