2

I am trying to create a grid that only has a domain between -0.8 and 0 and a range between -0.8, 0,8, with the grid not showing any positive X values. Thus far I have this:

enter image description here

But when I try to shrink the domain down the whole grid shrinks. What is the best way to create this graph on a smaller scale but retain the same size?

\begin{tikzpicture}
\draw[help lines, color=gray!50, dashed] (-10,-5) grid (0,5);
\draw[<-,ultra thick] (-10,0)--(0,0) node[right]{$x$};
\draw[<-,ultra thick] (0,5)--(0,-5) node[top]{$y$};

\end{tikzpicture}

Also, how would I proceed to draw points within this diagram?

  • Do you mean \begin{tikzpicture}[scale=0.7]? – Sigur Jul 13 '18 at 1:26
  • @Sigur that does not seem to do anything for me – theGuy05 Jul 13 '18 at 1:36
  • It is not clear what you want. If you want to change the arrows length, you have to change the end points. What do you mean by smaller scale but retain the same size? What is scale for you? – Sigur Jul 13 '18 at 2:04
  • step=5mm as grid option could be useful – Sigur Jul 13 '18 at 2:05
4

You might find pgfplots and its axis environment useful. pgfplots is a package for plotting data or functions, that is based on TikZ. It does take a bit more setup, and it isn't always better than plain TikZ (that depends on the specifics of the diagram), but perhaps this is a case where it can be of help.

I've added some comments before the different options I added to the axis environment, so hopefully should be somewhat clear what they do. Do ask if anything is unclear. Also, the pgfplots manual is a good reference.

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  % axis lines along center, not on outer edges
  axis lines=center,
  % make axis lines thick
  axis line style={thick},
  % move arrow tip of x-axis to start of line
  x axis line style={stealth-},
  % set the range of the axis
  xmin=-0.8, xmax=0,
  ymin=-0.8, ymax=0.8,
  % distance between the ticks, so distance between grid lines
  xtick distance=0.1,
  ytick distance=0.1,
  % remove ticklabels
  xticklabels={},
  yticklabels={},
  % set size of axis box
  width=8cm, height=8cm,
  scale only axis,
  % add grid, and change its style
  grid,
  grid style={help lines,color=gray!50, dashed},
  % add axis labels
  xlabel={$x$},
  ylabel={$y$},
  % move xlabel right of axis end point (default is above left)
  xlabel style={right}
]

% plot points at the given list of coordinates
\addplot [only marks,mark=*] coordinates {(-0.5,0.5) (-0.2,0) (-0.4,-0.3)};

\end{axis}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.