You can add every axis/.append style={font=\tiny},
before every axis x label/.style
. In this way you don't need to use \tiny
in x-y-z-labels.
To hide z axis just add hide z axis,
after axis z line=center
. I believe that if you put only axis z line=none
you are hiding only the axis line but not the ticks that are the short lines in your image. They are in that position because with axis z line=none
the z-axis
is no more centered.
\documentclass{memoir}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{
compat=newest, % Allows drawing of circles.
standard/.style={
axis equal,
axis line style=help lines,
axis x line=center,
axis y line=center,
axis z line=center,
hide z axis,
every axis/.append style={font=\tiny},
every axis x label/.append style={
at={(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0,0)},xshift=0.5em},
every axis y label/.append style={
at={(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax},0)},yshift=0.7em},
every axis z label/.append style={
at={(axis cs:0,0,\pgfkeysvalueof{/pgfplots/zmax})},xshift=0.5em}
}
}
{\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
standard,
xmin=-1, xmax=1,
ymin=-1, ymax=1,
zmin=0, zmax=2,
xtick={-1,1},
xticklabels={$-2r$,$2r$},
ytick={-1,1},
yticklabels={$-2r$,$2r$},
xlabel=$x$,
ylabel=$y$,
zlabel=$z$
]
% Draw Square
\draw[green] (axis cs: -0.5,0.86602540378,0) --
(axis cs: -0.5,-0.86602540378,0) --
(axis cs: -0.5,-0.86602540378,1.73205080757) --
(axis cs: -0.5,0.86602540378,1.73205080757) --
(axis cs: -0.5,0.86602540378,0);
\draw[blue] (axis cs: 0,0,0)
ellipse [
x radius=1, y radius=1];
\end{axis}
\end{tikzpicture}
\vspace{0.5 cm}
}
\end{document}
Image with font=\tiny
![enter image description here](https://i.stack.imgur.com/EiS16.jpg)
Image without font=\tiny
![enter image description here](https://i.stack.imgur.com/nREac.jpg)
You could achieve this by patching the internal macro that is responsible for typesetting the labels to only typeset the label if it fits completely inside the bounding box:
![](https://i.stack.imgur.com/coe0g.png)
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepackage{calc}
\makeatletter
% #1: the axis (x,y or z)
% #2: the location where to place it.
\def\pgfplots@show@ticklabel@@#1#2{%
\pgf@process{#2}%
% define a leniency factor here, so we can remove all labels, which are
% \leniency* labeldim from the border.
\def\leniency{0.5}%
\setlength{\pgf@xa}{\widthof{\csname pgfplots@#1ticklabel\endcsname}}%
\setlength{\pgf@ya}{\heightof{\csname pgfplots@#1ticklabel\endcsname}}%
\pgfmathtruncatemacro\labelfits{
and(
and(
(\pgf@x-\leniency*\pgf@xa)>0,
(\pgf@picmaxx-\pgf@x-\leniency*\pgf@xa)>0
),
and(
(\pgf@y-\leniency*\pgf@ya)>0,
(\pgf@picmaxy-\pgf@y-\leniency*\pgf@ya)>0
))}%
\ifnum\labelfits=1%
% Typeset the label!
\pgfinterruptboundingbox
% What makes this complicated is the 'ticklabel cs' feature.
% What we need is to compute the MAXIMUM LENGTH over each tick
% label IN DIRECTION OF THE OUTER NORMAL.
%
% This needs to
% 1. enable bounding box computation even in case of
% 'overlay',
% 2. projection of the bounding box in direction of the outer
% normal,
% 3. update of the bounding box if 'overlay' is not active.
\begingroup
%
% prepare step (1.):
\pgfkeysalso{%
/tikz/every node/.append code={%
\ifpgf@relevantforpicturesize
\gdef\pgfplots@show@ticklabel@@update@BB{1}%
\else
\gdef\pgfplots@show@ticklabel@@update@BB{0}%
\fi
\pgf@relevantforpicturesizetrue
}%
}%
%
% Compute and remember the position '#2':
\pgf@process{#2}%
\edef\pgfplots@ticklabel@at@x{\the\pgf@x}%
\edef\pgfplots@ticklabel@at@y{\the\pgf@y}%
%
% ok, generate the label!
\node at (\pgfplots@ticklabel@at@x,\pgfplots@ticklabel@at@y) {\csname pgfplots@#1ticklabel\endcsname};%
%
% compute the label's dimensions, step (2.):
\pgfplots@ticklabel@maxtickdimen@updateforcurrentpath
{#1}
{\pgf@x=\pgfplots@ticklabel@at@x\space\pgf@y=\pgfplots@ticklabel@at@y\space}%%
%
% prepare step (3.): update of bounding box:
\if\pgfplots@show@ticklabel@@update@BB1%
\xdef\pgfplots@glob@TMPa{%
\pgf@xa=\the\pgf@picminx\space
\pgf@xb=\the\pgf@picminy\space
\pgf@ya=\the\pgf@picmaxx\space
\pgf@yb=\the\pgf@picmaxy\space
\noexpand\pgf@protocolsizes{\pgf@xa}{\pgf@xb}%
\noexpand\pgf@protocolsizes{\pgf@ya}{\pgf@yb}%
\noexpand\pgf@resetpathsizes
}%
\else
\global\let\pgfplots@glob@TMPa=\relax
\fi
\endgroup
\endpgfinterruptboundingbox
\begingroup
\pgfplots@glob@TMPa
\endgroup
\fi
}%
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
axis lines=middle,
]
\addplot {sin(deg(x/5))};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
You can set the text of the 'scale label' manually by using the
manual:
forscaled x ticks
:I used tikz to create a text node rotated in the other direction (-90). This works well, but the positioning of the node is not yet the original. I don't know what exactly you want here, so i left it that way.![enter image description here](https://i.stack.imgur.com/3fR8q.png)
In my opinion, scaled ticks are quite ugly. Why is the value so big (ranging in thousands)? Perhaps you can change your unit? I don't know what data the xaxis holds, but maybe you could use kilometers instead of meters, hours instead of seconds and so on. In my experience, this also better reflects the data and actually helps understanding of it. Let's say we are talking about time here. If the xaxis was scaled in seconds, why would you care? This would be a process more happening in the scale of minutes or even fractions of hours. You would not think "I need around 900 seconds to the station", instead you would talk about 15 minutes.