Skip to content

Commit

Permalink
Record eingefügt, um einfach die Legendennamen überschreiben zu können.
Browse files Browse the repository at this point in the history
  • Loading branch information
kt86 committed Jan 18, 2025
1 parent 5dc40a8 commit 27d08aa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
52 changes: 27 additions & 25 deletions src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ static Figure createFigureNkvChange(Table table, String yName, String yName2, in
/**
* Für NKV vergleich-Plot mit 3 Kurven.
* */
static Figure createFigureNkvChange(Table table, String title, String xName, String yName1, String yName2, String yName3, String xAxisTitle, String yAxisTitle, int markerSize) {
static Figure createFigureNkvChange(Table table, String title, String xName,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y1,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y2,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y3,
String xAxisTitle, String yAxisTitle, int markerSize) {

double maxX = 20.;
double maxY = 20.;
Expand All @@ -369,39 +373,34 @@ static Figure createFigureNkvChange(Table table, String title, String xName, Str
table = table.sortDescendingOn(xName);

Axis yAxis = Axis.builder().type(Type.LINEAR)
.range(Double.min(0., 1.1 * table.numberColumn(yName1).min()), maxY)
.range(Double.min(0., 1.1 * table.numberColumn(y1.data()).min()), maxY)
.title(yAxisTitle)
.titleFont( defaultFont )
.build();

// Axis yAxis2 = Axis.builder().type(Type.LINEAR)
// .range(Double.min(0., 1.1 * table.numberColumn(yName2).min()), maxY)
// .title(yName2)
// .titleFont( defaultFont )
// .build();

Layout layout = Layout.builder(title)
.xAxis(xAxis)
.yAxis(yAxis)
// .yAxis2(yAxis2)
.width(RunLocalCsvScrapingKMT_EWGT.plotWidth)
.titleFont( defaultFont )
.build();

Trace y1overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName1))
Trace y1overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y1.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName1)
.name(y1.name())
.marker(Marker.builder().color("blue").size(markerSize).build())
.build();

Trace y2overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName2))
Trace y2overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y2.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName2)
.name(y2.name())
.marker(Marker.builder().color("red").size(markerSize).build())
.build();

Trace y3overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName3))
Trace y3overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y3.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName3)
.name(y3.name())
.marker(Marker.builder().color("orange").size(markerSize).build())
.build();

Expand Down Expand Up @@ -430,11 +429,15 @@ static Figure createFigureNkvChange(Table table, String title, String xName, Str
* Elatizitäten Unterschiede
*
**/
static Figure createFigureElaChange(Table table, String title, String xName, String yName1, String yName2, String yName3, String xAxisTitle, String yAxisTitle, int markerSize) {
static Figure createFigureElaChange(Table table, String title, String xName,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y1,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y2,
RunLocalCsvScrapingKMT2_hEART.DataNamaRecord y3,
String xAxisTitle, String yAxisTitle, int markerSize) {


double maxX = table.numberColumn( xName ).max() * 1.1;
double maxY = calculateMaxValue(table, List.of(yName1, yName2, yName3)) * 1.1;
double maxY = calculateMaxValue(table, List.of(y1.data(), y2.data(), y3.data())) * 1.1;

// double maxX = 20.;
// double maxY = 20.;
Expand All @@ -447,36 +450,35 @@ static Figure createFigureElaChange(Table table, String title, String xName, Str

table = table.sortDescendingOn(HeadersKN.NKV_ORIG);


Axis yAxis = Axis.builder()
.type(Type.LINEAR)
.range(Double.min(0., 1.1 * table.numberColumn(yName2).min()), maxY)
.range(Double.min(0., 1.1 * table.numberColumn(y2.data()).min()), maxY)
.title(yAxisTitle)
.titleFont( defaultFont )
.build();


Layout layout = Layout.builder( title)
.xAxis(xAxis)
.yAxis(yAxis)
.titleFont( defaultFont )
.width(RunLocalCsvScrapingKMT_EWGT.plotWidth)
.build();

Trace y1overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName1))
Trace y1overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y1.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName1)
.name(y1.name())
.marker(Marker.builder().color("blue").size(markerSize).build())
.build();

Trace y2overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName2))
Trace y2overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y2.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName2)
.name(y2.name())
.marker(Marker.builder().color("red").size(markerSize).build())
.build();

Trace y3overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(yName3))
Trace y3overX = ScatterTrace.builder(table.numberColumn(xName), table.numberColumn(y3.data()))
.text(table.stringColumn(Headers.PROJECT_NAME).asObjectArray())
.name(yName3)
.name(y3.name())
.marker(Marker.builder().color("orange").size(markerSize).build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,21 @@ private static void plotKMTforHeartFigures(Table table) throws IOException {
//####
figures.add( Pair.create( Figures2KN.createHeader1( "Kombiniert" ), null ) );

fig = FiguresKMT.createFigureElaChange(table, "Changes in addtl. vkm depending on calculation approaches", ADDTL_PKWKM_ORIG, ADDTL_PKWKM_EL06, ADDTL_PKWKM_EL0306_HALF, ADDTL_PKWKM_FROM_TTIME_29_HALF_InklBVWP, "original additional mileage (mio vkm/a) from BVWP 2030", "updated additional mileage (mio vkm/a)", 8);
var y1 = new DataNamaRecord(ADDTL_PKWKM_EL06, "elasticity = 0.6");
var y2 = new DataNamaRecord(ADDTL_PKWKM_EL0306_HALF, "reduced");
var y3 = new DataNamaRecord(ADDTL_PKWKM_FROM_TTIME_29_HALF_InklBVWP, "from travel Time gains");

fig = FiguresKMT.createFigureElaChange(table, "Changes in additional vkm/a depending on calculation approach", ADDTL_PKWKM_ORIG, y1, y2, y3, "original additional mileage (mio vkm/a) from BVWP 2030", "updated additional mileage (mio vkm/a)", 8);
figures.add( Pair.create( Figures2KN.createHeader2( "Kombiniert die verschiedenen Ansätze"), Collections.singletonList( fig )));

//
figures.add( Pair.create( Figures2KN.createHeader1( "NKV" ), null ) );
figures.add( Pair.create( Figures2KN.createHeader2( "Kombiniert die verschiedenen Ansätze - Co2-Preis BVWP"),null));

fig = FiguresKMT.createFigureNkvChange(table, "Changes in BCR depending on calculation approaches", NKV_ORIG_EN, NKV_ADDTL_PKWKM_EL06, NKV_ADDTL_PKWKM_EL0306_HALF, NKV_ADDTL_PKWKM_FROM_TTIME_29_HALF_InklBVWP, "original BCR from BVWP 2030", "updated BCR", 8);
y1 = new DataNamaRecord(NKV_ADDTL_PKWKM_EL06, "elasticity = 0.6");
y2 = new DataNamaRecord(NKV_ADDTL_PKWKM_EL0306_HALF, "reduced");
y3 = new DataNamaRecord(NKV_ADDTL_PKWKM_FROM_TTIME_29_HALF_InklBVWP, "from travel Time gains");
fig = FiguresKMT.createFigureNkvChange(table, "Changes in BCR depending on calculation approach", NKV_ORIG_EN, y1, y2, y3, "original BCR from BVWP 2030", "updated BCR", 8);
figures.add( Pair.create( Figures2KN.createHeader2( "Kombiniert die verschiedenen Ansätze"), Collections.singletonList( fig )));

plotFigures("multiplot_hEART.html", figures);
Expand All @@ -161,8 +168,6 @@ private static void plotKMTforHeartFigures(Table table) throws IOException {

}



private static void plotsKNsFigures(Table table, String PLUS_110_PCT) throws IOException {
final String NKV_ORIG_CAPPED5 = addCap( 5, table, HeadersKN.NKV_ORIG );
Figures1KN figures1 = new Figures1KN(table, NKV_ORIG_CAPPED5 );
Expand Down Expand Up @@ -562,4 +567,6 @@ private static void plotFigures(String outputFileString, List<Pair<String, List<
new Browser().browse(outputFile);
}


public record DataNamaRecord(String data, String name) {};
}

0 comments on commit 27d08aa

Please sign in to comment.