Graphics, Figures & TablesLabeling lines in my graph

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
DMOC
Posts: 2
Joined: Sat Feb 05, 2011 9:58 pm

Labeling lines in my graph

Post by DMOC »

Hello everyone,

I'm somewhat new to Latex, and I was giving a shot at trying to create my own graph.

Code: Select all

\setlength{\unitlength}{1cm}
\begin{picture}(1,1)
\put(0,-2){\vector(0,1){6}}
\put(-1,0){\vector(1,0){5}}
\put(0,1){\line(1,-1){3}}
\put(0,-1){\line(1,1){3}}
\put(0,1){\line(3,-1){3}}
\end{picture}
Let's say the code I have above lets me insert 3 line segments into an x-y graph. My question is, what's the easiest or best way to label the lines so that their equations are shown? I would like to be able to label the x and y axis as well.

Another brief question: how do I get arrows to go on both sides of a line segment? I have a \vector code but that only puts arrows on one side.

Thanks if you can offer help.

I used TeXShop for my Mac.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Labeling lines in my graph

Post by localghost »

It's amazing that some people still use the picture environment from vanilla LaTeX for graphs. Take a look at common graphics packages like pgf/tikZ or pstricks to get what you want.


Best regards and welcome to the board
Thorsten
Post Reply