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

كيف أُنشئ جدول مع نقط سوداء بداخل الخانات على LaTeX؟

K@m@l

السؤال

لدي هذا الكود على LaTeX:

\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz,amsmath}
\usetikzlibrary{arrows}%
\usepackage[np,autolanguage]{numprint}
\begin{document}

\begin{tikzpicture}%
    \draw[step=1cm,black,thin] (0,0) grid (5,5);
    %\foreach \x in {0, 1,...,5} { \node [anchor=north] at (\x,-0.2) {0.0}; }
    %\foreach \y in {0, 1,...,5} { \node [anchor=east] at (-0.2,\y) {\y}; }
    \node at (-0.5,0) {0.0};
    \node at (-0.5,1) {0.2};
    \node at (-0.5,2) {0.4};
    \node at (-0.5,3) {0.6};
    \node at (-0.5,4) {0.8};
    \node at (-0.5,5) {1.0};
    \node at (0,-0.5) {0.0};
    \node at (1,-0.5) {0.2};
    \node at (2,-0.5) {0.4};
    \node at (3,-0.5) {0.6};
    \node at (4,-0.5) {0.8};
    \node at (5,-0.5) {1.0};
    \draw [fill=black, thin] (0.5,2.5) circle [radius=0.05];
    \draw [fill=black, thin] (1.5,0.5) circle [radius=0.05];
    \draw [fill=black, thin] (2.5,4.5) circle [radius=0.05];
    \draw [fill=black, thin] (3.5,1.5) circle [radius=0.05];
    \draw [fill=black, thin] (4.5,3.5) circle [radius=0.05];
\end{tikzpicture}%

\end{document}

ما أريد فعله هو إدراج جدول بأرقام على جانبيه الأسفل والجانبي، مع إضافة نقط سوداء في بعض الخانات، فكيف أفعل ذلك؟

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

Recommended Posts

  • 0

كل ما في الأمر أنك تحتاج إلى حلقات تكرار foreach كتلك المُستعملة في مجال البرمجة، وباختصار نستعملها لتكرار وظيفة ما أوشيفرة، بهذا الشكل:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz}

\begin{document}    
\begin{tikzpicture}
    \draw[step=1cm,black,thin] (0,0) grid (5,5);
    \foreach \xtick in {0,...,5} {\pgfmathsetmacro\result{\xtick * .2} \node at (\xtick,-0.5) {\pgfmathprintnumber{\result}}; }
    \foreach \ytick in {0,...,5} {\pgfmathsetmacro\result{\ytick * .2} \node at (-.5,\ytick) {\pgfmathprintnumber{\result}}; }
    \foreach \x/\y in {.5/2.5, 1.5/.5, 2.5/4.5, 3.5/1.5, 4.5/3.5}{\draw [fill=black, thin] (\x,\y) circle [radius=0.05];}
\end{tikzpicture}   
\end{document}

مما سينتج عنه الجدول التالي:

e45l0.thumb.png.7a8aa66e21cb2a030c36966f

إذا أردت رسم المزيد من البيانات على الجدول، استعمل الدالة pgfplots:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        ,x=5cm,y=5cm
        ,grid=major
        ,major grid style={thick,black}
        ,xmin=0, xmax=1
        ,ymin=0, ymax=1
        ]
    \addplot[black, mark=*, only marks] table {
        .1 .5 
        .3 .1
        .5 .9
        .7 .3
        .9 .7 
    };
    \end{axis}
\end{tikzpicture}
\end{document}

 

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

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

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

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

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   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.

  • إعلانات

  • تابعنا على



×
×
  • أضف...