3

I am new to latex and this is my first post, so I am doing my best. I am plotting data (csv file) with pgfplots and so far it is working. But there some things I want to change and can not find the solution elsewhere.

Problems (Picture is down below)

  1. Since my data is going into the billions a "10^8" is being displayed to adjust the y-axis which is in single digits. Since I already have the y-axis labeled as "... in $ Billions" I do not want that adjustment. Is there maybe a simple command or do I have to adjust my data?

  2. The top x-axis as well as the left y-axis have "tick lines". Which command do I have to use to elimate those?

Thank you very much :)

This is my code so far:

\usepackage{pgfplots}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture} \begin{axis}[height=9cm, width=\textwidth,
    legend pos=north west,
    xmin=1995,
    xmax=2018,
    x tick label style={/pgf/number format/1000 sep=},every axis plot/.append style={ultra thick},
    ymin=0,
    ymajorgrids,
    xlabel=Year,
    ylabel=Trade in \$ Billions],
\addplot table [ x=Year, y=Export, col sep=semicolon] {data.csv};
\addlegendentry{$Exports$}
\addplot table [ x=Year, y=Import, col sep=semicolon] {data.csv};
\addlegendentry{$Imports$}
\addplot table [ x=Year, y=Total Trade, col sep=semicolon] {data.csv};
\addlegendentry{$Total Trade$}
\end{axis}
\end{tikzpicture}
\end{document}

In the top left corner

Pasq
  • 31

1 Answers1

4
  • To hide the exponent "10^8" of y-axis, use ytick scale label code/.code={}
  • To remove the ticks on top and right axes, use xtick pos=lower, ytick pos=left, as suggested in this answer. These two options are both initialized to both.

To learn more, you can search for the mentioned option names in the manual of package pgfplots.

\documentclass{article}
\usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \begin{axis}[ ymajorgrids, title={Before} ] \addplot coordinates { (20,0.0005) (40,0.0010) (60,0.0020) }; \end{axis} \end{tikzpicture} \qquad % \begin{tikzpicture} \begin{axis}[ ymajorgrids, title={After}, ytick scale label code/.code={}, xtick pos=lower, ytick pos=left ] \addplot coordinates { (20,0.0005) (40,0.0010) (60,0.0020) }; \end{axis} \end{tikzpicture} \end{document}

enter image description here

muzimuzhi Z
  • 26,474
  • Thank you very much! Always impressed by the speed and kindness of this community :D – Pasq Dec 23 '20 at 22:52