Skip to content

Instantly share code, notes, and snippets.

@hyuki0000
Created November 26, 2016 11:09
Show Gist options
  • Select an option

  • Save hyuki0000/1a18e78f82a7647d382c232fcbd67a52 to your computer and use it in GitHub Desktop.

Select an option

Save hyuki0000/1a18e78f82a7647d382c232fcbd67a52 to your computer and use it in GitHub Desktop.
y = 90/x (1 <= x <= 90) のグラフで格子点をプロットする
\documentclass[dvipdfmx,a4paper,10pt]{jsbook}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{calc}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line join=round,line cap=round,>=latex,x=1mm,y=1mm]
\tikzset{AXIS/.style={color=black,thin,->}}
\tikzset{GRID/.style={color=gray!50!white,very thin}}
\def\MINT{0}\def\MAXT{90}\def\MINX{0}\def\MAXX{90}\def\MINY{0}\def\MAXY{90}
\draw[AXIS] (\MINX,0) -- (\MAXX,0);
\draw[AXIS] (0,\MINY) -- (0,\MAXY);
\foreach \t in {\MINT,...,\MAXT} {
\draw[GRID] (\MINX,\t) -- (\MAXX,\t);
\draw[GRID] (\t,\MINY) -- (\t,\MAXX);
}
\newcounter{xy}
\foreach \x in {\MINX,...,\MAXX} {
\foreach \y in {\MINY,...,\MAXY} {
\setcounter{xy}{\x*\y}
\ifthenelse{\value{xy}=\MAXT} {
\fill[red] (\x,\y) circle (1.5pt);
\ifthenelse{\x < \y} {
\draw (\x,\y) node[above right] {\tiny$(\x,\y)$};
}{
\draw (\x,\y) node[below left] {\tiny$(\x,\y)$};
};
}{};
}
}
\end{tikzpicture}
\end{document}
@hyuki0000
Copy link
Copy Markdown
Author

178hyper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment