draw labels for x2 axis only if necessary

- added tics every 5 percentage points
This commit is contained in:
2018-05-01 08:07:04 +02:00
parent bfcbd0a451
commit 1d8f31808e
3 changed files with 22 additions and 29 deletions

View File

@@ -11,6 +11,10 @@ public interface AggregateHandler {
void addGnuplotDefinitions(StringBuilder result, String separator, Collection<DataSeries> dataSeries);
default void appendln(final StringBuilder builder, final String string) {
builder.append(string + "\n");
}
default void appendfln(final StringBuilder builder, final String format, final Object... args) {
builder.append(String.format(format + "\n", args));
}

View File

@@ -5,41 +5,35 @@ import java.util.Collection;
import org.lucares.recommind.logs.DataSeries;
public class PercentileAggregate implements AggregateHandler{
public class PercentileAggregate implements AggregateHandler {
@Override
public CustomAggregator createCustomAggregator(Path tmpDir) {
public CustomAggregator createCustomAggregator(final Path tmpDir) {
return new PercentileCustomAggregator(tmpDir);
}
public PercentileAggregate() {
}
@Override
public void addGnuplotDefinitions(StringBuilder result, String separator, Collection<DataSeries> dataSeries) {
// TODO still neeeded?
public void addGnuplotDefinitions(final StringBuilder result, final String separator,
final Collection<DataSeries> dataSeries) {
appendln(result, "set x2label \"Percentile\"");
appendln(result, "set format x2 \"%.0f%%\"");
appendln(result, "set x2tics 5");
appendln(result, "set x2range [\"0\":\"100\"]");
}
@Override
public void addPlots(StringBuilder result, Collection<DataSeries> dataSeries) {
for (DataSeries dataSerie : dataSeries) {
public void addPlots(final StringBuilder result, final Collection<DataSeries> dataSeries) {
for (final DataSeries dataSerie : dataSeries) {
final AggregatedData aggregatedData = dataSerie.getAggregatedData();
if (aggregatedData != null){
appendfln(
result,
"'%s' using 1:2 notitle with lines axes x2y1 lw 2 %s, \\", //
aggregatedData.getDataFile().getAbsolutePath(),//
if (aggregatedData != null) {
appendfln(result, "'%s' using 1:2 notitle with lines axes x2y1 lw 2 %s, \\", //
aggregatedData.getDataFile().getAbsolutePath(), //
dataSerie.getStyle()//
);
// appendfln(result, "'%s' using 1:2 title '%s' with lines axes x2y1 %s, \\", //
// aggregatedData.getDataFile().getAbsolutePath(),//
// dataSerie.getTitle()+" " +aggregatedData.getLabel(), // title
// dataSerie.getStyle()//
// );
}
}
}

View File

@@ -28,11 +28,6 @@ public class GnuplotFileGenerator {
appendfln(result, "set xlabel \"%s\"", xAxis.getXlabel());
appendfln(result, "set xrange [\"%s\":\"%s\"]", xAxis.getFrom(), xAxis.getTo());
appendfln(result, "set x2label \"Percentile\"");
appendln(result, "set format x2 \"%.0f%%\"");
appendfln(result, "set x2tics");
appendfln(result, "set x2range [\"0\":\"100\"]");
final long graphOffset = settings.getYAxisScale() == AxisScale.LINEAR ? 0 : 1;
appendfln(result, "set yrange [\"" + graphOffset + "\":]");