Graphics, Figures & TablesPosition of Axis Scale Factor in Plot

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sprungfeld
Posts: 1
Joined: Tue Mar 04, 2014 1:51 am

Position of Axis Scale Factor in Plot

Post by sprungfeld »

Hi,

I am trying to create a plot with two separate y-axes. The right y-axis is units "*10^5". However, the multiplication caption is not positioned correctly. I use the following code:

Code: Select all

\begin{tikzpicture}
  \begin{axis}[
    axis y line* = left,
    xlabel = grid size $l$,
    ylabel = \textcolor{blue}{\footnotesize$\blacksquare$}
indices per $\mathcal{T}$,
    ymode = log,
    log origin=infty
  ]
    \addplot[color=blue,mark=x] coordinates {
      (15000,317.631)
      (20000,182.318)
      (40000,49.3089)
      (80000,14.4933)
      (160000,5.02436)
      (320000,2.37795)
      (500000,1.81145)
      (640000,1.62701)
      (1280000,1.29392)
      (2560000,1.18447)
    };
  \end{axis}

  \begin{axis}[
    hide x axis,
    ylabel near ticks,
    axis y line*=right,
    ylabel={\textcolor{red}{\footnotesize$\blacksquare$}  number of $\mathcal{T}_{pot}$}
  ]
    \addplot[color=red,mark=x] coordinates {
      (15000,40819)
      (20000,41179)
      (40000,41179)
      (80000,42720)
      (160000,44312)
      (320000,44866)
      (640000,98610)
      (1280000,168980)
      (2560000,184202)
    };
    \draw[black,dashed] (axis cs:500000,0) -- (axis cs:500000,200000);
    \draw (axis cs:500000,200000) node[below right] {$l_r$};
  \end{axis}
\end{tikzpicture}
This produces the output in the attached picture. However, I want the "*10^5" in the upper right corner to be aligned right of the y-axis, not left of it. It should be aligned just like the tick labels for the right y-axis.

Any help is highly appreciated!
Attachments
The obtained output.
The obtained output.
pgfplots-axis-scale-factor.png (22.25 KiB) Viewed 8869 times
Last edited by localghost on Tue Mar 04, 2014 10:44 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

feuersaenger
Posts: 34
Joined: Sun Oct 16, 2011 5:56 pm

Position of Axis Scale Factor in Plot

Post by feuersaenger »

Hi,

You can reconfigure the position by means of styles. In your case, the style definition

Code: Select all

        every y tick scale label/.style={
            at={(yticklabel* cs:1.03,0cm)},
            anchor=near yticklabel
        },
given inside of the option list for your second axis appears to do what you want it to:
P.png
P.png (19.18 KiB) Viewed 8833 times
This choice resembles the one used by normal ticks, i.e. the tick scale label will be aligned just like tick labels. As long as you can still distinguish it from standard tick labels, this should be fine.

Kind regards

Christian
Post Reply