1

I want to reproduce this graphic using tkz-base and tkz-euclide :graphic

But I strugle to print the Y axis on the left, as all the x's are negative.

Here's a MWE :

\begin{tikzpicture}
\tkzInit[xmin=-150000,
    xmax=0,
    xstep=10000,
    ymax=18,
    ymin=4,
    ystep=2]
\tkzDrawX\tkzLabelX[orig,step=50000]
\tkzDrawY\tkzLabelY[orig]
\end{tikzpicture}

All I have is :

problem

As you can see, the y axis is on the right while I want it on the left.

2
  • Might I suggest using PGFplots? As far as I know tkz-euclide is more designated to geometric drawings. And your plot seems to be quite easy with PGFplots... Jan 18, 2017 at 16:58
  • @GuilhermeZanotelli The tkz collection also has tkz-fct for plotting stuff. The \tkzAxe stuff is defined in tkz-base. Mar 5, 2017 at 10:42

2 Answers 2

0

I don't know how to modify the tkz stuff to do that, but as mentioned in a comment pgfplots is a good package for plotting stuff. Here is a starting point:

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  % set axis limits
  xmin=-150000,
  xmax=9000,
  ymin=0,
  ymax=18,
  % draw axis lines only on left and bottom (default is to make a box)
  axis y line=left,
  axis x line=bottom,
  % disable having a common scale factor for all ticklabels
  scaled x ticks=false,
  % separation between ticks on x-axis
  xtick distance={50000},
  % number of minor ticks
  minor x tick num=4,
  % disable having e.g. -1e5 as a tick
  xticklabel style={/pgf/number format/fixed}
]

% plot some random numbers, just for example
\addplot +[domain=-150000:0] {rnd*10 + 4};
\end{axis}
\end{tikzpicture}
\end{document}
3

If you really want to stick with tkz-base then the only way [that I can find] to do this is to reset your axes to be positive, and then put the labels in by hand.

\documentclass[border=5mm]{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
    \tkzInit[xmin=0, xmax=150000, xstep=10000, ymin=4, ymax=18, ystep=2]
    \tkzDrawX[label={}]
    \tkzDefPoint(150000,3.8){C}\tkzLabelPoint[below](C){Actuel}
    \tkzDefPoint(100000,3.8){B}\tkzLabelPoint[below](B){$-50\,000$}
    \tkzDefPoint( 50000,3.8){A}\tkzLabelPoint[below](A){$-100\,000$}
    \tkzDrawY\tkzLabelY[orig=false]
\end{tikzpicture}
\end{document}

enter image description here

Of course, if you do this you would need to adjust your data points so that the years are positive too. I guess you can think of them as "years since 150,000 years ago". But as noted in the comments, you might find it easier to use pgfplots.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .