# How to draw the graph of function x+y=100

Following is the code for drawing the graph of x+y=4. Now i am thinking to draw the graph of x+y=100 for that what are the necessary changes in the given codes.

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,bindingoffset=0.2in,left=0.7in,right=0.7in,top=0.7in,bottom=0.7in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
\begin{tikzpicture}
\draw[thick,latex-latex] (-2,0) -- (5,0)node[right]{$x$};
\draw[thick,latex-latex] (0,-2) -- (0,5)node[above]{$y$};
\node at (-0.3,-0.3) {O};
\foreach \x in {-1,1,2,3,4}{
\node[fill,circle,inner sep=1.5pt,label=below:$\x$] at (\x,0) {};
\node[fill,circle,inner sep=1.5pt,label=left:$\x$] at (0,\x) {};
}
\draw[thick,stealth-stealth, shorten >= -2cm, shorten <= -2cm,name path =b ] (0,4) -- (4,0)
node[pos=0.65,above,sloped] {};
\foreach \x/\y/\name in {0/4/B,4/0/A}{
\node[fill,circle,inner sep=2.5pt,label={[inner sep=0pt]above right:\name($\x, \y$)}] at (\x,\y) {};
}
\end{tikzpicture}
\end{document}

• Have a look at pgfplots – JPi Dec 2 '15 at 10:27

There are several ways, one solution would be to change all coordinates to the 0 to 100 scale and fix the scaling, another would be to calculate the new labels from the given coordinates (everything times 25). Faster than that would be to fake everything by separating labels from coordinates. Example based on a more minimal version of your code below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[thick,latex-latex] (-2,0) -- (5,0)node[right]{$x$};
\draw[thick,latex-latex] (0,-2) -- (0,5)node[above]{$y$};
\node at (-0.3,-0.3) {O};
\foreach \x/\l in {-1/-25,1/25,2/50,3/75,4/100}{
\node[fill,circle,inner sep=1.5pt,label=below:$\l$] at (\x,0) {};
\node[fill,circle,inner sep=1.5pt,label=left:$\l$] at (0,\x) {};
}
\draw[thick,stealth-stealth, shorten >= -2cm, shorten <= -2cm,name path =b ] (0,4) -- (4,0)
node[pos=0.65,above,sloped] {};
\foreach \x/\y/\name/\m/\n in {0/4/B/0/100,4/0/A/100/0}{
\node[fill,circle,inner sep=2.5pt,label={[inner sep=0pt]above right:\name($\m, \n$)}] at (\x,\y) {};
}
\end{tikzpicture}
\end{document}


But I second JPi's suggestion: Become familiar with pgfplots.