Skip to content

Commit cf5ee5f

Browse files
committed
WIP
1 parent 30e6633 commit cf5ee5f

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/main/java/nz/cri/gns/NZSHM22/opensha/inversion/joint/reporting/JointRuptureRatePlot.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,34 @@ public List<String> plot(
141141
for (int b = 0; b < numBins; b++) {
142142
func.set(b, bins[b]);
143143
}
144-
func.setName(cat);
144+
String legend = cat.contains("+") ? cat : cat + " only";
145+
func.setName(legend);
145146
funcs.add(func);
146147
chars.add(new PlotCurveCharacterstics(PlotLineType.SOLID, 2f, COLORS.get(i)));
147148
}
148149

150+
// Find smallest nonzero y value across all curves
151+
double minNonZeroY = Double.MAX_VALUE;
152+
for (DiscretizedFunc func : funcs) {
153+
for (int b = 0; b < func.size(); b++) {
154+
double y = func.getY(b);
155+
if (y > 0 && y < minNonZeroY) {
156+
minNonZeroY = y;
157+
}
158+
}
159+
}
160+
Range yRange = null;
161+
if (minNonZeroY < Double.MAX_VALUE) {
162+
// Find max y for upper bound
163+
double maxY = 0;
164+
for (DiscretizedFunc func : funcs) {
165+
for (int b = 0; b < func.size(); b++) {
166+
maxY = Math.max(maxY, func.getY(b));
167+
}
168+
}
169+
yRange = new Range(minNonZeroY / 10.0, maxY * 2.0);
170+
}
171+
149172
PlotSpec spec =
150173
new PlotSpec(
151174
funcs,
@@ -162,7 +185,7 @@ public List<String> plot(
162185

163186
HeadlessGraphPanel gp = PlotUtils.initHeadless(PlotPreferences.getDefaultAppPrefs());
164187
gp.setTickLabelFontSize(20);
165-
gp.drawGraphPanel(spec, false, true, xRange, null);
188+
gp.drawGraphPanel(spec, false, true, xRange, yRange);
166189

167190
String prefix = "joint_rupture_mfds";
168191
PlotUtils.writePlots(resourcesDir, prefix, gp, 1000, 850, true, true, false);

0 commit comments

Comments
 (0)