Guest User

scaling styles

a guest
Sep 29th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 2.57 KB | None | 0 0
  1. \documentclass{standalone}
  2.  
  3. \usepackage{pgfplots}
  4.  
  5. \newcommand{\getpgfkey}[1]{\pgfkeysvalueof{/pgfplots/#1}}
  6. \newcommand{\xmin}[0]{\getpgfkey{xmin}}
  7. \newcommand{\xmax}[0]{\getpgfkey{xmax}}
  8. \newcommand{\ymin}[0]{\getpgfkey{ymin}}
  9. \newcommand{\ymax}[0]{\getpgfkey{ymax}}
  10.  
  11. \pgfmathsetmacro{\yminscaledDOWN}{\pgfkeysvalueof{/pgfplots/ymin}}
  12.  
  13. \usepgfplotslibrary{groupplots}
  14. \pgfplotsset{
  15. xscalingdown/.style={
  16. x coord trafo/.code=\pgfmathparse{##1/(1e#1)},
  17. every axis/.append code={%
  18. \edef\pgfmathresult{\xmax/(1e#1)}\global\let\xmaxSCALED=\pgfmathresult
  19. \edef\pgfmathresult{\xmin/(1e#1)}\global\let\xminSCALED=\pgfmathresult
  20. },
  21. xlabel style={
  22. append after command={
  23. node [rotate=90, anchor=base west] at (\tikzlastnode.base east) {$\cdot{10^{#1}}$}
  24. }
  25. }
  26. },
  27. xscalingup/.style={
  28. x coord trafo/.code=\pgfmathparse{##1*(1e#1)},
  29. every axis/.append code={%
  30.     \edef\pgfmathresult{\xmax*(1e#1)}\global\let\xmaxSCALED=\pgfmathresult
  31.     \edef\pgfmathresult{\xmin*(1e#1)}\global\let\xminSCALED=\pgfmathresult
  32. },
  33. xlabel style={
  34. append after command={
  35. node [rotate=90, anchor=base west] at (\tikzlastnode.base east) {$\cdot{10^{{-1}#1}}$}
  36. }
  37. }
  38. },
  39. yscalingdown/.style={
  40. y coord trafo/.code=\pgfmathparse{##1/(1e#1)},
  41. every axis/.append code={%
  42.     \pgfmathparse{\ymax/(1e#1)}\global\let\ymaxSCALED=\pgfmathresult
  43.     \pgfmathparse{\ymin/(1e#1)}\global\let\yminSCALED=\pgfmathresult
  44. },
  45. ylabel style={
  46. append after command={
  47. node [rotate=90, anchor=base west] at (\tikzlastnode.base east) {$\cdot{10^{#1}}$}
  48. }
  49. }
  50. },
  51. yscalingup/.style={
  52. y coord trafo/.code=\pgfmathparse{##1*(1e#1)},
  53. every axis/.append code={%
  54. \pgfmathparse{\ymax*(1e#1)}\global\let\ymaxSCALED=\pgfmathresult
  55. \pgfmathparse{\ymin*(1e#1)}\global\let\yminSCALED=\pgfmathresult
  56. },
  57. ylabel style={
  58. append after command={
  59. node [rotate=90, anchor=base west] at (\tikzlastnode.base east) {$\cdot{10^{{-1}#1}}$}
  60. }
  61. }
  62. },
  63. }
  64.  
  65. \begin{document}
  66. \begin{tikzpicture}
  67. \begin{groupplot}[
  68. group style={
  69.     horizontal sep=0.2cm,
  70.     group size=2 by 1,
  71.     ylabels at=edge left,
  72.     yticklabels at=edge left,
  73. },
  74. ymin=-100, ymax=1300,
  75. xlabel={The label for the x-axis},
  76. ylabel={Some y-values},
  77. xscalingdown=3,
  78. yscalingdown=3,
  79. ]
  80. \nextgroupplot
  81. \addplot[only marks] coordinates{(2000,1200) (3000,500)};
  82. \draw[ultra thick, dashed, blue] (axis cs:\xminSCALED,\yminSCALED) rectangle (axis cs:\xmaxSCALED,\ymaxSCALED);
  83. \nextgroupplot
  84. \addplot[only marks] coordinates{(2100,1000) (2800,1200)};
  85. \draw[ultra thick, dashed, blue] (axis cs:\xminSCALED,\yminSCALED) rectangle (axis cs:\xmaxSCALED,\ymaxSCALED);
  86. \end{groupplot}
  87. \end{tikzpicture}
  88. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment