0

I have the MWE below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}


\begin{document}


\begin{tikzpicture}[{x=(1mm,0)},{y=(0,1mm)}]
\small

\def\verticallength{50}
\def\horizontallength{80}
\def\ticksemilength{2}

\draw
    (0, 0)
        rectangle(\horizontallength, \verticallength)
    ;

\foreach \stp in {0,1,...,10}{
    \pgfmathparse{\stp/10}
    \pgfmathprintnumberto{\pgfmathresult}{\coeff}
    \pgfmathparse{1900+\stp*10}
    \pgfmathprintnumberto{\pgfmathresult}{\years}

    \draw
        (\ticksemilength, \stp*\verticallength/10)--++
            (-2*\ticksemilength, 0)
            node[left]{\coeff}
        (\stp*\horizontallength/10, \ticksemilength)--++
        (0, -2*\ticksemilength)
            node[below]{\years}
        ;
    }

\end{tikzpicture}

\end{document}

The rectangle here represents a PNG figure of the same width and size.

My questions are: How to make the second vertical value to show 0.1 instead of $1 \cdot 10^{-1}$? How to remove the comma from the horizontal values?

Thank you.

1 Answer 1

1

For a better result, and a more efficient job I recommend you implement axis in your solution.

Here is the code

\documentclass[]{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
 scaled ticks = false,
 tick label style={/pgf/number format/fixed},
 xlabel={years},
 ylabel={coefficient},
 width=16cm,
 height=10cm,
 xtick={1900,1910,...,2000},
 ytick={0,0.1,0.2,...,1},
 xmin=1900,
 xmax=2000,
 ymin=-0.1,
 ymax=1]
\end{axis}

\end{tikzpicture}
\end{document}

Resulting in a more elegant output

enter image description here

1
  • Hi, @Mauramz. Thank you for the solution. But your output still has that comma separating the thousands in the horizontal axis. You present a workaround of my problem, not the actual solution, since I precisely asked (1) how to remove the commas from numbers at horizontal values and (2) how to represent the first vertical value as <1> instead of <1*E-1>. Anyhow, imagine that I try your solution, how do I add my rectangular picture (PNG format) to fit the plot area?
    – Brasil
    Commented Aug 14, 2019 at 18:58

You must log in to answer this question.

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