4

How can I move the axis multiplier in a polar plot? In the following MWE, the axis multiplier is over the ticks and prevent the plot to be nice and readable.

\documentclass[crop=true,border=2mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\usepgfplotslibrary{dateplot} 
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{graphicx}

%\pgfplotsset{compat=1.7}

\newlength\figureheight
\newlength\figurewidth
\setlength\figureheight{4cm}
\setlength\figurewidth{4cm}

\begin{document}

\begin{tikzpicture} %[scale=1.0]
    \begin{polaraxis}[%
        axis on top,
        width = \figurewidth,
        height = \figureheight,
        scale only axis,
        ymin=5.e5, ymax=1.5e6,
        xtick      ={0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330},
        xticklabels={0, $\frac{\pi}6$, $\frac{\pi}3$, $\frac{\pi}2$, $\frac{2\pi}3$, $\frac{5\pi}6$, $\pi$ , $\frac{7\pi}6$, $\frac{4\pi}3$, $\frac{3\pi}2$, $\frac{5\pi}3$, $\frac{11\pi}6$},
        ytick = {5e5, 1.e6, 1.5e6},
    ]
    \addplot [data cs=polarrad, mark=*, draw=black, smooth]
        table [%
        col sep=comma, trim cells=true, %
        x=x, y=y,] %
        {mydata.dat};
    \end{polaraxis}
\end{tikzpicture}

\end{document}

The content of mydata.dat is as follows.

# mydata
x,y
0.0000,1.1686E+06
0.0175,1.1686E+06
0.0349,1.1446E+06
0.0524,1.1165E+06
0.0698,1.1034E+06
0.0873,1.1038E+06
0.1047,1.1059E+06
0.1222,1.1317E+06
0.1396,1.1500E+06
0.1571,1.1372E+06
0.1745,1.1173E+06
0.1920,1.1218E+06
0.2094,1.1257E+06
0.2269,1.1203E+06
0.2443,1.1078E+06
0.2618,1.1043E+06
0.2793,1.1239E+06
0.2967,1.1228E+06
0.3142,1.0912E+06
0.3316,1.0909E+06

The result is shown in the following figure. As can be seen .10^6 is on the xtick=0 and makes the plot hard to read.

enter image description here

I have run an update on all the packages including pgfplots. However, I still see ("C:\Program Files (x86)\MiKTeX 2.9\pgfplots_1.7.tds\tex\generic\pgfplots\libs\ tikzlibrarypgfplots.polar.code.tex") in the log file, which I assume it is using compat=1.7.

Regardless of the version, Which seems solvable, is there any way to manually set the position of the axis multiplier or at least fine tune its position?

Thanks.

  • I just ran your MWE exactly as posted, but the axis multiplier is in a different position (still not ideal location, but there must be other issues). My results: i.stack.imgur.com/vei9a.png – Paul Gessler Mar 2 '14 at 21:33
  • @PaulGessler: I fixed the problem with the version. Now I get similar results like the one you posted. Would it be possible to fine tune the axis multiplier in the picture you kindly posted? The reason I am asking this is that I have several plots similar to this with larger exponents for example .10^16 which might lie on the ticks. Is there any way to shift the multiplier a little bit away from the plot? The following link shows the result for the larger multiplier: tinypic.com/r/2gxlpvp/8 – AFP Mar 2 '14 at 21:41
  • 2
    The location is apparently hard-coded; see here for details (case is the same for polar axes). As Jake suggests, adding ylabel near ticks to the axis options will shift the multiplier. If this doesn't put the multiplier in an acceptable location, I'm not sure what else to do. – Paul Gessler Mar 2 '14 at 21:53
  • @PaulGessler: thanks. It put it in another position which does not overlap with the ticks. However, I wish I could modify the position when I am not using ylabel near ticks as it places the multiplier in a great position and makes the plot super professional. I wish the position of axis multiplier could be fine-tuned. – AFP Mar 2 '14 at 22:28
5

You were looking for the every y tick scale label/.style option. I enclose an example.

%! *latex mal-polar-plot.tex
\documentclass[crop=true,border=2mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\usepgfplotslibrary{dateplot} 
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{graphicx}
\pgfplotsset{compat=1.10}

\newlength\figureheight
\newlength\figurewidth
\setlength\figureheight{4cm}
\setlength\figurewidth{4cm}

\usepackage{filecontents}
\def\malfile{mal-data.txt}
\begin{filecontents*}{\malfile}
# mydata
x,y
0.0000,1.1686E+06
0.0175,1.1686E+06
0.0349,1.1446E+06
0.0524,1.1165E+06
0.0698,1.1034E+06
0.0873,1.1038E+06
0.1047,1.1059E+06
0.1222,1.1317E+06
0.1396,1.1500E+06
0.1571,1.1372E+06
0.1745,1.1173E+06
0.1920,1.1218E+06
0.2094,1.1257E+06
0.2269,1.1203E+06
0.2443,1.1078E+06
0.2618,1.1043E+06
0.2793,1.1239E+06
0.2967,1.1228E+06
0.3142,1.0912E+06
0.3316,1.0909E+06
\end{filecontents*}

\begin{document}

\begin{tikzpicture} %[scale=1.0]
    \begin{polaraxis}[%
        axis on top,
        width = \figurewidth,
        height = \figureheight,
        scale only axis,
        ymin=5.e5, ymax=1.5e6,
        xtick      ={0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330},
        xticklabels={0, $\frac{\pi}6$, $\frac{\pi}3$, $\frac{\pi}2$, $\frac{2\pi}3$, $\frac{5\pi}6$, $\pi$ , $\frac{7\pi}6$, $\frac{4\pi}3$, $\frac{3\pi}2$, $\frac{5\pi}3$, $\frac{11\pi}6$},
        ytick = {5e5, 1.e6, 1.5e6},
        every y tick scale label/.style={at={(0,1)}},
    ]
    \addplot [data cs=polarrad, mark=*, draw=black, smooth]
        table [%
        col sep=comma, trim cells=true, %
        x=x, y=y,] %
        {\malfile};
    \end{polaraxis}
\end{tikzpicture}

\end{document}

mwe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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