From 8d55ef4e5fda01f0871b7469389d3f418d7f9671 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Sat, 23 Nov 2019 14:36:32 +0100 Subject: [PATCH] make sure labels for cumulative distribution don't overlap --- .../plot/api/CumulativeDistributionHandler.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java index aa41921..d179bf9 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java @@ -38,12 +38,24 @@ public class CumulativeDistributionHandler implements AggregateHandler { result.setType(Type.Number); result.setAxis(GnuplotAxis.X2); // TODO determine automatically result.setFormat("%.0f%%"); - result.setTicIncrement(5); + result.setTicIncrement(computeTicIncrement(settings)); result.setFrom("0"); result.setTo("100"); return result; } + private int computeTicIncrement(GnuplotSettings settings) { + int widthByFontSize = settings.getWidth()/GnuplotSettings.TICKS_FONT_SIZE; + if (widthByFontSize < 50) { + return 20; + } + else if (widthByFontSize < 75) { + return 10; + }else { + return 5; + } + } + @Override public void addPlot(StringBuilder result, AggregatedData aggregatedData, LineStyle lineStyle, Optional title) { appendfln(result, "'%s' using 1:2 %s with lines axes x2y1 lw 2 %s, \\", //