relative figure width

This commit is contained in:
Motiejus Jakštys 2021-05-19 22:57:47 +03:00 committed by Motiejus Jakštys
parent ef94a601c4
commit d46542162c
3 changed files with 19 additions and 22 deletions

View File

@ -75,6 +75,7 @@ fig8-definition-of-a-bend.pdf: layer2img.py Makefile .faux_test
fig5-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test fig5-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
python ./layer2img.py \ python ./layer2img.py \
--sizediv=2 \
--group1-table=wm_debug \ --group1-table=wm_debug \
--group1-where="name='fig5' AND stage='bbends' AND gen=1" \ --group1-where="name='fig5' AND stage='bbends' AND gen=1" \
--group2-cmap=1 \ --group2-cmap=1 \
@ -84,6 +85,7 @@ fig5-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
fig5-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test fig5-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test
python ./layer2img.py \ python ./layer2img.py \
--sizediv=2 \
--group1-table=wm_debug \ --group1-table=wm_debug \
--group1-where="name='fig5' AND stage='cinflections' AND gen=1" \ --group1-where="name='fig5' AND stage='cinflections' AND gen=1" \
--group2-cmap=1 \ --group2-cmap=1 \
@ -93,6 +95,7 @@ fig5-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test
inflection-1-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test inflection-1-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
python ./layer2img.py \ python ./layer2img.py \
--sizediv=2 \
--group1-table=wm_debug \ --group1-table=wm_debug \
--group1-where="name='inflection-1' AND stage='bbends' AND gen=1" \ --group1-where="name='inflection-1' AND stage='bbends' AND gen=1" \
--group2-cmap=1 \ --group2-cmap=1 \
@ -102,6 +105,7 @@ inflection-1-gentle-inflection-before.pdf: layer2img.py Makefile .faux_test
inflection-1-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test inflection-1-gentle-inflection-after.pdf: layer2img.py Makefile .faux_test
python ./layer2img.py \ python ./layer2img.py \
--sizediv=2 \
--group1-table=wm_debug \ --group1-table=wm_debug \
--group1-where="name='inflection-1' AND stage='cinflections' AND gen=1" \ --group1-where="name='inflection-1' AND stage='cinflections' AND gen=1" \
--group2-cmap=1 \ --group2-cmap=1 \

View File

@ -6,22 +6,13 @@ import matplotlib.pyplot as plt
from matplotlib import rc from matplotlib import rc
#CMAP = 'Set3' # CMAP = 'Set3' # this is nice too
CMAP = 'tab20c' CMAP = 'tab20c'
INCH = 25.4 # mm
BOUNDS = ('xmin', 'ymin', 'xmax', 'ymax') BOUNDS = ('xmin', 'ymin', 'xmax', 'ymax')
BLACK, GREEN, ORANGE, PURPLE = '#000000', '#1b9e77', '#d95f02', '#7570b3' BLACK, GREEN, ORANGE, PURPLE = '#000000', '#1b9e77', '#d95f02', '#7570b3'
PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm" PSQL_CREDS = "host=127.0.0.1 dbname=osm user=osm password=osm"
def plt_size(string):
if not string:
return None
try:
w, h = string.split("x")
return float(w) / INCH, float(h) / INCH
except Exception as e:
raise argparse.ArgumentTypeError from e
def parse_args(): def parse_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@ -38,9 +29,10 @@ def parse_args():
parser.add_argument('--group3-where') parser.add_argument('--group3-where')
parser.add_argument('--group3-cmap', type=bool) parser.add_argument('--group3-cmap', type=bool)
parser.add_argument('--sizediv',
default=1, type=float, help='Size divisor')
parser.add_argument('-o', '--outfile', metavar='<file>') parser.add_argument('-o', '--outfile', metavar='<file>')
parser.add_argument(
'--size', type=plt_size, help='Figure size in mm (WWxHH)')
parser.add_argument('--clip', type=float, nargs=4, metavar=BOUNDS) parser.add_argument('--clip', type=float, nargs=4, metavar=BOUNDS)
return parser.parse_args() return parser.parse_args()
@ -66,8 +58,7 @@ def main():
rc('text', usetex=True) rc('text', usetex=True)
fig, ax = plt.subplots() fig, ax = plt.subplots()
if args.size: fig.set_figwidth(8.27 / args.sizediv)
fig.set_size_inches(args.size)
if c := args.clip: if c := args.clip:
ax.set_xlim(left=c[0], right=c[2]) ax.set_xlim(left=c[0], right=c[2])
ax.set_ylim(bottom=c[1], top=c[3]) ax.set_ylim(bottom=c[1], top=c[3])

View File

@ -220,6 +220,7 @@ This section defines vocabulary and terms as defined in the rest of the paper.
\item[Bend] is a subset of a line that humans perceive as a curve. For the \item[Bend] is a subset of a line that humans perceive as a curve. For the
purpose of this paper, the geometric definition is complex and is purpose of this paper, the geometric definition is complex and is
discussed in section~\onpage{sec:definition-of-a-bend}. discussed in section~\onpage{sec:definition-of-a-bend}.
\end{description} \end{description}
\section{Automated tests} \section{Automated tests}
@ -235,7 +236,7 @@ The full set of test geometries is visualized in
figure~\onpage{fig:test-figures}. The figure includes arrows depicting line figure~\onpage{fig:test-figures}. The figure includes arrows depicting line
direction. direction.
\begin{figure}[H] \begin{figure}[h]
\centering \centering
\includegraphics[width=\linewidth]{test-figures} \includegraphics[width=\linewidth]{test-figures}
\caption{Line geometries for automated test cases} \caption{Line geometries for automated test cases}
@ -269,7 +270,7 @@ purposes) using the following algorithm:
\section{Definition of a Bend} \section{Definition of a Bend}
\label{sec:definition-of-a-bend} \label{sec:definition-of-a-bend}
\begin{figure}[H] \begin{figure}[h]
\centering \centering
\includegraphics[width=\linewidth]{fig8-definition-of-a-bend} \includegraphics[width=\linewidth]{fig8-definition-of-a-bend}
\caption{Originally Figure 8: detected bends are highlighted} \caption{Originally Figure 8: detected bends are highlighted}
@ -308,12 +309,13 @@ when a single vertex is moved outwards the end of the bend.
The example in this section was clear, but insufficient: it does not specify The example in this section was clear, but insufficient: it does not specify
how many vertices should be included when calculating the end-of-bend how many vertices should be included when calculating the end-of-bend
inflection. We chose the iterative approach -- as long as the angle is "right" inflection. We chose the iterative approach -- as long as the angle is "right"
and the distance is decreasing, the algorithm should keep going; practically and the distance is decreasing, the algorithm should keep re-assigning vertices
not having an upper bound on the number of iterations. to different bends; practically not having an upper bound on the number of
iterations.
Additional example, not found in the original paper, is illustrated in Additional example, not found in the original paper, is illustrated in
figure~\ref{fig:inflection-1-gentle-inflection}, which moves two vertices figure~\ref{fig:inflection-1-gentle-inflection}, which re-assigns two vertices
instead of one. to the next bend instead of one.
\begin{figure}[h] \begin{figure}[h]
\centering \centering
@ -326,7 +328,7 @@ instead of one.
\includegraphics[width=\textwidth]{inflection-1-gentle-inflection-after} \includegraphics[width=\textwidth]{inflection-1-gentle-inflection-after}
\caption{After applying the inflection rule} \caption{After applying the inflection rule}
\end{subfigure} \end{subfigure}
\caption{Originally Figure 5: gentle inflections at the ends of the bend} \caption{Gentle inflection at the end of the bend when multiple vertices is moved.}
\label{fig:inflection-1-gentle-inflection} \label{fig:inflection-1-gentle-inflection}
\end{figure} \end{figure}