Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to draw a shift arrow from one point to the next, but it doesn't seem to work. Here is my code:

\begin{tikzpicture}
%Axis
\draw [<->] (0,5) node (yaxis) [left] {$P$} -- (0,0) node[below left] {(0,0)} -- (5,0) node (xaxis) [below] {$B$};
%Title
\draw (3,5) node[above, xshift=-10] {Corporate Bonds};
%Supply
\draw[->, red] (1,1) coordinate (s_1) -- (4,4) coordinate (s_2) node[above right] {$B^{s}$};
%Demand
\draw[->, blue] (1,4) coordinate (d_1) -- (4,1) coordinate (d_2) node[below right] {$B^{d}$};
%Save Intersection (equilibrium)
\coordinate (c) at (intersection of s_1--s_2 and d_1--d_2);
%Intersection (equilibrium)
\draw[dashed] (yaxis |- c) node[left] {$P^e$} -| (xaxis -| c) node[below] {$B^e$};
\fill[black] (c) circle (2pt);
%Demand After
\draw[->, blue, xshift=20, yshift=20] (1,4) coordinate (d_1) -- (4,1) coordinate (d_2) node[below right] {$B^{d'}$};
%Save Intersection (after equilibrium)
\coordinate (d) at (intersection of s_1--s_2 and d_1--d_2);
%Intersection (after equilibrium)
\draw[dashed] (yaxis |- d) node[left] {$P'$} -| (xaxis -| d) node[below] {$B'$};
\fill[black] (d) circle (2pt);
\draw[->, xshift=20, yshift=20] (c) -- (d); // <-- this is the arrow part I want to do
\end{tikzpicture}

Here is the picture:

enter image description here

I have the arrows pointing the right directions, but I want the arrows to shift away from the two intersection points so that the reader can see it better. However, when I use « xshift » or « yshift », it doesn't even shift the arrows at all; the arrows simply stay put where they are.

share|improve this question
    
May be you can also consider draw a shorter arrow with shorten < and shorten > options: \draw[|->, xshift=20, yshift=20, shorten >=3pt, shorten <=3pt] (c) -- (d); –  Ignasi Jun 14 at 8:29

3 Answers 3

up vote 3 down vote accepted

You can't shift or rotate a shape by global operation, you have to specify it explicitely for each shape or by canvas transformations.

Edit :

Another solution is to use :

\draw[->,thick] let \p1 = ($(d)-(c)$)
    in
    ($(c)+1.5*(\y1,-\x1)$)--++(\x1,\y1) ;

The 1.5 is only a factor to move the arrow right (if >0) and left (if <0).

enter image description here

\documentclass[tikz]{standalone}
\usepackage{}
\usetikzlibrary{}

\begin{document}

\begin{tikzpicture}
%Axis
\draw [<->] (0,5) node (yaxis) [left] {$P$} -- (0,0) node[below left] {(0,0)} -- (5,0) node (xaxis) [below] {$B$};
%Title
\draw (3,5) node[above, xshift=-10] {Corporate Bonds};
%Supply
\draw[->, red] (1,1) coordinate (s_1) -- (4,4) coordinate (s_2) node[above right] {$B^{s}$};
%Demand
\draw[->, blue] (1,4) coordinate (d_1) -- (4,1) coordinate (d_2) node[below right] {$B^{d}$};
%Save Intersection (equilibrium)
\coordinate (c) at (intersection of s_1--s_2 and d_1--d_2);
%Intersection (equilibrium)
\draw[dashed] (yaxis |- c) node[left] {$P^e$} -| (xaxis -| c) node[below] {$B^e$};
\fill[black] (c) circle (2pt);
%Demand After
\draw[->, blue, xshift=20, yshift=20] (1,4) coordinate (d_1) -- (4,1) coordinate (d_2) node[below right] {$B^{d'}$};
%Save Intersection (after equilibrium)
\coordinate (d) at (intersection of s_1--s_2 and d_1--d_2);
%Intersection (after equilibrium)
\draw[dashed] (yaxis |- d) node[left] {$P'$} -| (xaxis -| d) node[below] {$B'$};
\fill[black] (d) circle (2pt);
\draw[->,thick] ([xshift=20, yshift=-20]c) -- ([xshift=20, yshift=-20]d); // <-- this is the arrow part I want to do
\end{tikzpicture}
\end{document}
share|improve this answer
    
this solution and the one above are all wonderful. thank you for your all your time! –  ben Jun 14 at 9:21
    
I don't understand your first sentence. Can you elaborate a bit? Do you mean the transformation won't apply ? –  percusse Jun 14 at 9:21
    
@percusse If I correctly understood the pgfmanual, a canvas transformation can move a shape in the contrary a coordinate tranformation can't. Did I missunderstood ? –  Tarass Jun 14 at 9:33
    
@Tarass No no I just didn't understand the sentence. I think I get what you mean but curious about global operation part. You know curiosity kills the cat :) –  percusse Jun 14 at 9:36
    
@percusse Please feel free to rephrase ma sentence, as you know both tikz and english better than me. I don't undersand the cat's story ;-) –  Tarass Jun 14 at 9:43

This solution observes that you have used label d_1 and d_2 nodes twice for the blue lines because xshfit=20 and yshift=20 were used to draw the second blue line. If you are willing to change the second d_1 and d_2 into dd_1 and dd_2 and the coordinate (d) accordingly then one may use the relative coordinate to draw lines between blue lines B^d and B^{d'}.

\draw[->, black,] ($(d_1)!0.8!(d_2)$) -- ($(dd_1)!0.8!(dd_2)$); % decimal numbers are between [0 1]. 
\draw[<-, black,] ($(d_1)!0.3!(d_2)$) -- ($(dd_1)!0.3!(dd_2)$); % 

enter image description here

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shadows,patterns,calc}

\begin{document}

\begin{tikzpicture}
%Axis
\draw [<->] (0,5) node (yaxis) [left] {$P$} -- (0,0) node[below left] {(0,0)} -- (5,0) node (xaxis) [below] {$B$};
%Title
\draw (3,5) node[above, xshift=-10] {Corporate Bonds};
%Supply
\draw[->, red] (1,1) coordinate (s_1) -- (4,4) coordinate (s_2) node[above right] {$B^{s}$};
%Demand
\draw[->, blue] (1,4) coordinate (d_1) -- (4,1) coordinate (d_2) node[below right] {$B^{d}$};
%Save Intersection (equilibrium)
\coordinate (c) at (intersection of s_1--s_2 and d_1--d_2);
%Intersection (equilibrium)
\draw[dashed] (yaxis |- c) node[left] {$P^e$} -| (xaxis -| c) node[below] {$B^e$};
\fill[black] (c) circle (2pt);
%Demand After
\draw[->, blue, xshift=20, yshift=20] (1,4) coordinate (dd_1) -- (4,1) coordinate (dd_2) node[below right] {$B^{d'}$};
%Save Intersection (after equilibrium)
\coordinate (d) at (intersection of s_1--s_2 and dd_1--dd_2);  % change dd_1 and dd_2
%Intersection (after equilibrium)
\draw[dashed] (yaxis |- d) node[left] {$P'$} -| (xaxis -| d) node[below] {$B'$};
\fill[black] (d) circle (2pt);
\draw[->, black,] ($(d_1)!0.8!(d_2)$) -- ($(dd_1)!0.8!(dd_2)$); % <-- this is the arrow part I want to do
\draw[<-, black,] ($(d_1)!0.3!(d_2)$) -- ($(dd_1)!0.3!(dd_2)$); % <-- this is the arrow part I want to do
\end{tikzpicture}

\end{document}
share|improve this answer
    
Your solution is blue line dependent, in particular, in that lines have to be same length. Take a look at my edit. –  Tarass Jun 14 at 7:20
1  
@Tarass -- I understand your point. Actually, I was ready to post your first solution, but you are fast :)- so I had to think other solution, independent of yours, and the parallel feature of blue lines inspired this feasible solution. Thanks for the comment. –  Jesse Jun 14 at 7:33
    
thank you very much –  ben Jun 14 at 9:20

Another way is to use orthogonal specifiers (via calc library)

\draw[->] ($(c)!-20pt!90:(d)$) -- ($(d)!20pt!90:(c)$);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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