I would like to produce a graph like I attached.
I started with drawing a coordinate system and adding 3 points, to create a triangle, but the reference is not the origin of the coordinate system... How could I get the attached graph?
\begin{center}
\begin{tikzpicture}
\begin{axis}[
%Same unit length
axis equal,
scale=1.5,
transform shape,
axis lines=middle,
axis line style={Stealth-Stealth, thick},
xmin=-8.5,xmax=8.5,ymin=-8.5,ymax=8.5,
xtick distance=1,
ytick distance=1,
xlabel=$x$,
ylabel=$y$,
title={},
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle,
%For plot of functions domain
domain = -8:8
]
\addplot[blue] {-1/2*x} node[above,pos=1] {};
\addplot[red] {2*x} node[above,pos=1] {};
\draw (10,8) node[anchor=north] {a}
-- (13,8) node[anchor=north]{b}
-- (18,14) node[anchor=south]{c}
-- cycle;
\end{axis}
\end{tikzpicture}
\end{center}
pgfplots
andtkz-euclide
. Please edit your post to provide a "Minimal Working Example" (MWE) that starts with\documentclass
, includes all relevant\usepackage
commands, ends with\end{document}
and compiles without errors, even if it does not produce your desired output.pgfplots
for a graph like that but everything is possible. I think you should between plain TikZ andpgfplots
.\pgfplotsset{compat=1.11}
to the preamble. By default coordinates used for\draw
,\path
,\node
inside theaxis
environment ofpgfplots
is not given in the coordinates of theaxis
. To explicitly use the axis coordinate system, useaxis cs:
as a prefix in the coordinate, e.e.\draw (axis cs:0,0) ...
. Withcompat=1.11
or higher on the other hand,axis cs:
becomes the default, so it's not necessary to explicitly add it to the coordinates.