اذهب إلى المحتوى
  • 0

كيف أغيّر لون الخلفية على برنامج LaTeX إلى Grid؟

Badraoui

السؤال

بعد الكثير من البحث توصلت إلى رسم المنحنى التالي:

9UWev.png.1a27b17193e55ed2fb37c27426d179

بواسطة هذا الكود:

\documentclass{article}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{fillbetween}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
% Eixos
\begin{axis}[
grid,
axis x line=center,
axis y line=center,
xtick={-1,0,1},
ytick={-1,0,1},
xlabel={$x$},
ylabel={$y$},
xlabel style={below right},
ylabel style={above left},
xmin=-0.5,
xmax=1.1,
ymin=-0.5,
ymax=1.1]

% Função de cima contínua
\addplot[name path=f,domain=0:1,CCazul] {x};
% Função de baixo cintínua
\addplot[name path=g,domain=0:1,CCvermelho] {x^2};

% Função de cima pontilhada
\addplot[dashed, name path=fpont1,domain=-.5:0,CCazul] {x};
\addplot[dashed, name path=fpont2,domain=1:1.1,CCazul] {x};
% Função de baixo pontilhada
\addplot[dashed, name path=gpont1,domain=-.5:0,CCvermelho] {x^2};    
\addplot[dashed, name path=gpont2,domain=1:1.1,CCvermelho] {x^2};   

% Path
\path[name path=axis] (axis cs:0,0) -- (axis cs:1,0);

%Fill between
\addplot [
thick,
color=black,
fill=black, 
fill opacity=0.05
]
fill between[
of=f and g,
soft clip={domain=0:1},
];

% Labels dos nós
\node [color=CCazul] at (axis cs:  .55,  .8) {$f(x) = x$};
\node  [color=CCvermelho] at (axis cs:  0.9,  .4) {$g(x) = x^2$};
\end{axis}
\end{tikzpicture}

\end{document}

لكن ما أريده هو تغيير لون الخلفية إلى جدول Grid، و إظهار رقم فواصل x؟

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

لتغيير نسق الخلفية يمكنك استعمال { }=grid style مع تحديد مظهر الخلفية داخل المعقوفتين.

وبالتحديد لإظهار grid أو خلفية على شكل جدول سنستعمل minor tick num أو minor x tick num و minor y tick num .

أيضا لكتابة الدالتين بلونين مختلفين الأزرق والأحمر.

نستعمل الكود التالي

\documentclass[tikz]{standalone}
\usepackage{tikz,pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid=both,
grid style={red!15},
axis x line=center,
axis y line=center,
xtick={-1,0,1},
ytick={-1,0,1},
minor tick num=4,
xticklabel style={below left},
yticklabel style={below left},
xlabel={$x$},
ylabel={$y$},
xlabel style={below right},
ylabel style={above left},
xmin=-0.5,
xmax=1.1,
ymin=-0.5,
ymax=1.1]

\addplot[name path=f,domain=0:1,blue] {x};

\addplot[name path=g,domain=0:1,red] {x^2};

\addplot[dashed, name path=fpont1,domain=-.5:0,blue] {x};
\addplot[dashed, name path=fpont2,domain=1:1.1,blue] {x};

\addplot[dashed, name path=gpont1,domain=-.5:0,red] {x^2};    
\addplot[dashed, name path=gpont2,domain=1:1.1,red] {x^2};   

% Path
\path[name path=axis] (axis cs:0,0) -- (axis cs:1,0);

%Fill between
\addplot [
thick,
color=black,
fill=black, 
fill opacity=0.05
]
fill between[
of=f and g,
soft clip={domain=0:1},
];

\node[blue] at (axis cs:  .55,  .8) {$f(x) = x$};
\node[red] at (axis cs:  0.9,  .4) {$g(x) = x^2$};
\end{axis}
\end{tikzpicture}
\end{document}

لنحصل في الأخير على الشكل المُبين في الصورة:

95xYO.png.becd75d3cebab06e1f5e6008d1766a

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...