-
Notifications
You must be signed in to change notification settings - Fork 0
/
nomograph_example.tex
216 lines (211 loc) · 7.31 KB
/
nomograph_example.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
\documentclass[tikz,border=10pt]{standalone}
\usepackage{pdftexcmds,etoolbox}
%% From web page at https://tex.stackexchange.com/questions/175991/how-can-i-draw-nomograms-in-latex downloaded on 2 Apr 2020.
\makeatletter
\newif\ifroundedenabled%
\newif\ifscalemaxtomin%
\newif\ifscalefromzero%
\pgfkeys{/nomogram/.cd,
% keys for a single diagram
part 1/.style={},
part 2/.style={},
part 3/.style={},
single diagram/.cd,
scale max to min/.is if=scalemaxtomin,
scale max to min=false,
scale from zero/.is if=scalefromzero,
scale from zero=true,
at pos/.store in=\dgrposition,
at pos={(0,0)},
height/.store in=\dgrheight,
height=10cm,
min value/.store in=\minval,
min value=0,
max value/.store in=\maxval,
max value=10,
step/.store in=\incstep,
step=1,
horizontal rule width/.store in=\horulewidth,
horizontal rule width=1cm,
min step/.store in=\minstep,
min step={\incstep/2},
minor tick rule width/.store in=\minortickrulewidth,
minor tick rule width=3mm,
little tick rule width/.store in=\litteltickrulewidth,
little tick rule width=1mm,
tick direction/.store in=\tickpos,
tick direction=left,
label above/.store in=\lababove,
label above={},
label sloped/.store in=\labsloped,
label sloped={},
label above rotation/.store in=\rotation,
label above rotation=0,
diagram/.code={
\path \dgrposition node(A){};
\pgfgetlastxy{\xA}{\yA};
\ifscalemaxtomin%
\pgfmathsetmacro\sndval{\maxval-\incstep}
\foreach \y[count=\yi from 0] in {\maxval,\sndval,...,\minval}{
\global\let\maxitems\yi%
}%
\else%
\pgfmathsetmacro\sndval{\minval+\incstep}
\foreach \y[count=\yi from 0] in {\minval,\sndval,...,\maxval}{
\global\let\maxitems\yi%
}%
\fi
\draw(\xA,\yA)--++(0,\dgrheight)
node[pos=0.5,sloped,above]{\labsloped}
node[above,rotate=\rotation,transform shape]{\lababove};% vertical line+above label
\pgfmathsetmacro\actualstep{\dgrheight/\maxitems}%
% little ticks
\pgfmathsetmacro\littletickstep{\actualstep/10}
\foreach \y in {0,\littletickstep,...,\dgrheight}{
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\draw(\xA,\yA+\y pt) --++(-\litteltickrulewidth,0);
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\draw(\xA,\yA+\y pt) --++(\litteltickrulewidth,0);
\fi%
}%
% min step
\pgfmathsetmacro\mintickstep{\actualstep/2}
\ifscalemaxtomin%
\foreach \y [count=\yi from 0,
evaluate=\yi as \ytext using ((\maxval-\yi*\incstep+\yi*\incstep/2))]
in {0,\mintickstep,...,\dgrheight}{%
\ifnumodd{\yi}{% true
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\draw (\xA,\yA+\y pt) --++(-\minortickrulewidth,0)
node[left,font=\footnotesize]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\draw (\xA,\yA+\y pt) --++(\minortickrulewidth,0)
node[right,font=\footnotesize]{\pgfmathprintnumber{\ytext}};
\fi%
}{}%
}%
\else%
\foreach \y [count=\yi from 0,
evaluate=\yi as \ytext using ((\yi*\incstep+2*\minval)/2)] in
{0,\mintickstep,...,\dgrheight}{%
\ifnumodd{\yi}{% true
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\draw (\xA,\yA+\y pt) --++(-\minortickrulewidth,0)
node[left,font=\footnotesize]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\draw (\xA,\yA+\y pt) --++(\minortickrulewidth,0)
node[right,font=\footnotesize]{\pgfmathprintnumber{\ytext}};
\fi%
}{}%
}%
\fi%
% main step
\ifscalemaxtomin%
\ifscalefromzero%
\foreach \y[count=\yi from 0,
evaluate=\yi as \ytext using (\maxval-\yi*\incstep)] in
{0,\actualstep,...,\dgrheight}{%
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(-\horulewidth,0)
node[left]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(\horulewidth,0)
node[right]{\pgfmathprintnumber{\ytext}};
\fi%
}%
\else%
\foreach \y[count=\yi from 0,
evaluate=\yi as \ytext using (\maxval-\yi*\incstep)] in
{0,\actualstep,...,\dgrheight}{%
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(-\horulewidth,0)
node[left]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(\horulewidth,0)
node[right]{\pgfmathprintnumber{\ytext}};
\fi%
}%
\fi%
\else%
\ifscalefromzero%
\foreach \y[count=\yi from 0,
evaluate=\yi as \ytext using (\yi*\sndval+\minval)] in
{0,\actualstep,...,\dgrheight}{%
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(-\horulewidth,0)
node[left]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(\horulewidth,0)
node[right]{\pgfmathprintnumber{\ytext}};
\fi%
}%
\else%
\foreach \y[count=\yi from 0,
evaluate=\yi as \ytext using (\yi*\incstep+\minval)] in
{0,\actualstep,...,\dgrheight}{%
\ifnum\pdf@strcmp{\tickpos}{left}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(-\horulewidth,0)
node[left]{\pgfmathprintnumber{\ytext}};
\fi%
\ifnum\pdf@strcmp{\tickpos}{right}=\z@%
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\draw (\xA,\yA+\y pt) --++(\horulewidth,0)
node[right]{\pgfmathprintnumber{\ytext}};
\fi%
}%
\fi%
\fi%
}%
}
% that's just an alias for \node
\def\drawnomogrampart{\tikz@path@overlay{node}}
\makeatother
\begin{document}
\begin{tikzpicture}
\drawnomogrampart[/nomogram/single diagram/.cd,
height=7cm,
min value=50,
max value=130,
step=10,
label above=$\Delta v$,
scale from zero=false,
diagram]{};
\begin{scope}[rotate=-30,transform shape]
\drawnomogrampart[/nomogram/single diagram/.cd,
horizontal rule width=0.5cm,
height=8cm,
min value=0,
max value=0.901,% for rounding purposes
step=0.1,
label above rotation=30,
label above={$M_f=1-\textrm{e}^{-\Delta v/9.81*I_{sp}}$},
label sloped={Mass Fraction $(M_f)$},
tick direction=right,
diagram]{};
\end{scope}
\drawnomogrampart[/nomogram/single diagram/.cd,
scale from zero=false,
height=7cm,
scale max to min=true,
min value=400,
max value=2000,
step=200,
at pos={(7,0)},
tick direction=right,
label above=IPS (s),
diagram]{};
\end{tikzpicture}
\end{document}