عدة رسوم بيانية في شبكة باستخدام groupplots
حمّل مكتبة groupplots، وافتح بيئة groupplot مع group style={group size=2 by 1}، وابدأ كل رسم بـ \nextgroupplot.
رسمان جنبًا إلى جنب
ترتّب مكتبة groupplots عدة محاور في شبكة، بالحجم نفسه وبإطارات متحاذية. ويعني group size=2 by 1 عمودين وصفًا واحدًا. ويبدأ كل \nextgroupplot الخلية التالية، بترتيب القراءة.
رسمان في صف واحد
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={group size=2 by 1, horizontal sep=1.5cm},
width=6cm, height=4.5cm, xlabel=$t$,
]
\nextgroupplot[title={Position}, ylabel=$x$]
\addplot[blue, thick, domain=0:4, samples=40] {x^2/2};
\nextgroupplot[title={Velocity}, ylabel=$v$]
\addplot[red, thick, domain=0:4] {x};
\end{groupplot}
\end{tikzpicture}
\end{document}تنطبق الخيارات الموضوعة على groupplot على كل خلية؛ أما الخيارات الموضوعة على \nextgroupplot فتنطبق على تلك الخلية وحدها.
شبكة 2 في 2 بتسميات مشتركة
في الشبكة تتكرر تسميات علامات التدريج الداخلية وتسميات المحاور. يُبقي xlabels at=edge bottom وylabels at=edge left تسميات المحاور على الرسوم الخارجية فقط، ويفعل xticklabels at=edge bottom الشيء نفسه لتسميات علامات تدريج x.
أربعة رسوم بتسميات على الحواف الخارجية
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=2 by 2,
horizontal sep=1.2cm, vertical sep=1cm,
xlabels at=edge bottom, ylabels at=edge left,
xticklabels at=edge bottom,
},
width=5.5cm, height=4cm,
xlabel=$t$, ylabel=$y$, domain=0:6, samples=50,
]
\nextgroupplot \addplot[blue] {sin(deg(x))};
\nextgroupplot \addplot[red] {cos(deg(x))};
\nextgroupplot \addplot[teal] {exp(-x/2)};
\nextgroupplot \addplot[orange] {x/6};
\end{groupplot}
\end{tikzpicture}
\end{document}رسم رئيسي ولوحة للبواقي
يمكن أن تكون للخلايا ارتفاعات ونطاقات مختلفة. ومن التخطيطات الشائعة رسم للبيانات تحته لوحة صغيرة للبواقي، يشتركان في المحور x.
البيانات والبواقي
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={group size=1 by 2, vertical sep=0.4cm, xticklabels at=edge bottom},
width=8cm, xmin=0, xmax=5,
]
\nextgroupplot[height=5cm, ylabel={Signal}]
\addplot+[only marks] coordinates {(1,2.1) (2,3.9) (3,6.2) (4,7.8)};
\addplot[red, domain=0:5] {2*x};
\nextgroupplot[height=3cm, xlabel=$x$, ylabel={Residual}, ymin=-0.5, ymax=0.5]
\addplot+[only marks] coordinates {(1,0.1) (2,-0.1) (3,0.2) (4,-0.2)};
\addplot[gray, dashed, domain=0:5] {0};
\end{groupplot}
\end{tikzpicture}
\end{document}مفاتيح group style
| المفتاح | ما يفعله | في Scissor LaTeX |
|---|---|---|
group size=C by R | الأعمدة في الصفوف | يعمل |
horizontal sep، vertical sep | المسافة بين إطارات المحاور | يعمل |
xlabels at=edge bottom، ylabels at=edge left | تسميات المحاور على الرسوم الخارجية فقط (أو all) | يعمل |
xticklabels at=edge bottom، yticklabels at=edge left | تسميات علامات التدريج على الرسوم الخارجية فقط (أو all) | يعمل |
group name=g | اسم للإشارة إلى الخلايا، مثل g c1r1 | مقبول؛ لكن الإشارة إلى الخلايا غير مدعومة |
ما الذي يختلف عن تثبيت TeX
المكتبة جزء من pgfplots؛ راجع قسم "groupplots" في الدليل على CTAN: ctan.org/pkg/pgfplots. وابدأ بـ الرسوم البيانية باستخدام pgfplots إن كنت جديدًا على pgfplots.
راجع أيضًا الرسوم الخطية والمحاور اللوغاريتمية وpgfplots.
أسئلة وأجوبة
كيف أنشئ رسومًا فرعية في LaTeX؟
استخدم مكتبة groupplots من pgfplots: \usepgfplotslibrary{groupplots}، ثم \begin{groupplot}[group style={group size=2 by 2}] و\nextgroupplot واحدًا لكل رسم.
كيف أشارك تسميات المحاور في مجموعة رسوم؟
أضف xlabels at=edge bottom وylabels at=edge left إلى group style، واضبط xlabel وylabel على groupplot.
هل يمكن لرسمين أن يتشاركا مفتاح رسم واحدًا؟
لكل خلية مفتاح رسمها الخاص. ضع المفتاح في خلية واحدة وحدد موضعه باستخدام legend style={at={(x,y)}, anchor=...}.
كل مثال في هذه الصفحة ينضّده Scissor LaTeX عند بناء الموقع. آخر تحديث: 2026-11-07.