change color pallette to better show distinctive colors

The old method of creating brighter/darker colors was producing color
shades that did not look like the same color. E.g. a darker yellow
looked more like brown.
I am now trying to use hand crafted shades.
This commit is contained in:
2020-01-19 12:46:16 +01:00
parent 20a78b4625
commit 99e57cda24
7 changed files with 57 additions and 79 deletions

View File

@@ -84,7 +84,7 @@ public class BarChartHandler extends AggregateHandler {
gnuplotTitle(title), //
GnuplotLineType.Bar, //
gnuplotXYAxis(), //
lineStyle.brighter()//
lineStyle.asGnuplotLineStyleBright()//
);
}

View File

@@ -78,7 +78,7 @@ public class CumulativeDistributionHandler extends AggregateHandler {
aggregatedData.getDataFile().getAbsolutePath(), //
gnuplotTitle(title), //
gnuplotXYAxis(), //
lineStyle.darker()//
lineStyle.asGnuplotLineStyleBright()//
);
}

View File

@@ -62,7 +62,7 @@ public class HistogramHandler extends AggregateHandler {
aggregatedData.getDataFile().getAbsolutePath(), //
gnuplotTitle(title), //
gnuplotXYAxis(), //
lineStyle.darker()//
lineStyle.asGnuplotLineStyleDark()//
);
}

View File

@@ -55,7 +55,7 @@ public class ParallelRequestsAggregate extends AggregateHandler {
aggregatedData.getDataFile().getAbsolutePath(), //
gnuplotTitle(title), //
gnuplotXYAxis(), //
lineStyle.brighter().asGnuplotLineStyle()//
lineStyle.asGnuplotLineStyleDark()//
);
}

View File

@@ -1,55 +1,33 @@
package org.lucares.recommind.logs;
import java.awt.Color;
public class GnuplotColor {
private final String color; // hex: 00efcc
private GnuplotColor(String color) {
this.color = color;
private final String bright, normal, dark; // hex: 00efcc
private GnuplotColor(final String bright, final String normal, final String dark) {
this.bright = bright;
this.normal = normal;
this.dark = dark;
}
public static GnuplotColor byHex(String aHex) {
return new GnuplotColor(aHex);
public static GnuplotColor byHex(final String bright, final String normal, final String dark) {
return new GnuplotColor(bright, normal, dark);
}
public static GnuplotColor byAwtColor(Color color) {
final String hex = String.format("%02x%02x%02x", //
color.getRed(), //
color.getGreen(), //
color.getBlue()//
);
return new GnuplotColor(hex);
public String getBright() {
return bright;
}
public String getColor() {
return "rgb \"#" + color + "\"";
return normal;
}
public String getDark() {
return dark;
}
@Override
public String toString() {
return getColor();
}
Color toAwtColor() {
int red = Integer.parseInt(color.substring(0, 2), 16);
int green = Integer.parseInt(color.substring(2, 4), 16);
int blue = Integer.parseInt(color.substring(4, 6), 16);
return new Color(red, green, blue);
}
public GnuplotColor brighter() {
final Color brighterColor = toAwtColor().brighter();
return byAwtColor(brighterColor);
}
public GnuplotColor darker() {
final Color darkerColor = toAwtColor().darker();
return byAwtColor(darkerColor);
}
}

View File

@@ -24,27 +24,24 @@ public interface GnuplotColorPalettes {
* <div style="background-color: #FF69B4; display:inline; padding:
* 8px;">#FF69B4</div>
*/
List<GnuplotColor> GNUPLOT = Arrays.asList(//
GnuplotColor.byHex("9400D3"), // purple
GnuplotColor.byHex("009e73"), // green
GnuplotColor.byHex("56b4e9"), // light blue
GnuplotColor.byHex("e69f00"), // orange
GnuplotColor.byHex("f0e442"), // yellow
GnuplotColor.byHex("0072b2"), // blue
GnuplotColor.byHex("e51e10"), // red
GnuplotColor.byHex("FF69B4")// magenta
);
/*
* List<GnuplotColor> GNUPLOT = Arrays.asList(// GnuplotColor.byHex("9400D3"),
* // purple GnuplotColor.byHex("009e73"), // green
* GnuplotColor.byHex("56b4e9"), // light blue GnuplotColor.byHex("e69f00"), //
* orange GnuplotColor.byHex("f0e442"), // yellow GnuplotColor.byHex("0072b2"),
* // blue GnuplotColor.byHex("e51e10"), // red GnuplotColor.byHex("FF69B4")//
* magenta );
*/
List<GnuplotColor> GNUPLOT_REORDERED = Arrays.asList(//
GnuplotColor.byHex("0072b2"), // blue 00A2FF, 0091E6, 0072B2, 005180, 002840
GnuplotColor.byHex("e69f00"), // orange FFAE00, E69F00, BF8300, 805700, 402C00
GnuplotColor.byHex("9400D3"), // purple B300FF, A100E6, 9400D3, 590080, 2D0040
GnuplotColor.byHex("009e73"), // green
GnuplotColor.byHex("f0e442"), // yellow
GnuplotColor.byHex("e51e10"), // red
GnuplotColor.byHex("56b4e9"), // lightblue
GnuplotColor.byHex("FF69B4")// magenta
GnuplotColor.byHex("0060e6", "0051c2", "003580"), // blue 006aff, 0060e6, 0051c2, 003580, 001b40
GnuplotColor.byHex("E69F00", "BF8300", "805700"), // orange FFAE00, E69F00, BF8300, 805700, 402C00
GnuplotColor.byHex("A100E6", "9400D3", "590080"), // purple B300FF, A100E6, 9400D3, 590080, 2D0040
GnuplotColor.byHex("00e663", "00c254", "008037"), // green
GnuplotColor.byHex("FFFF00", "E6e600", "c2c200"), // yellow
GnuplotColor.byHex("FF2200", "e51e10", "C211a00"), // "FF2200","e51e10","C211a00","801100","400800"
GnuplotColor.byHex("67bee6", "57a1c2", "396980"), // "73d3ff", "67bee6", "57a1c2","396980","1d3540"
GnuplotColor.byHex("E040E6", "BD36C2", "7C2480")// "F947FF", "E040E6", "BD36C2", "7C2480", "3E1240"
);
/**
@@ -67,15 +64,13 @@ public interface GnuplotColorPalettes {
*
*
*/
List<GnuplotColor> MATPLOTLIB = Arrays.asList(//
GnuplotColor.byHex("1f77b4"), // blue
GnuplotColor.byHex("ff7f0e"), // orange
GnuplotColor.byHex("d62728"), // red
GnuplotColor.byHex("2ca02c"), // green
GnuplotColor.byHex("fdbb6c"), // light orange
GnuplotColor.byHex("b3df72"), // light green
GnuplotColor.byHex("feffbe")// light yellow
);
/*
* List<GnuplotColor> MATPLOTLIB = Arrays.asList(//
* GnuplotColor.byHex("1f77b4"), // blue GnuplotColor.byHex("ff7f0e"), // orange
* GnuplotColor.byHex("d62728"), // red GnuplotColor.byHex("2ca02c"), // green
* GnuplotColor.byHex("fdbb6c"), // light orange GnuplotColor.byHex("b3df72"),
* // light green GnuplotColor.byHex("feffbe")// light yellow );
*/
List<GnuplotColor> DEFAULT = GNUPLOT_REORDERED;
}

View File

@@ -10,23 +10,28 @@ public class LineStyle {
this.dashType = dashType;
}
public String asGnuplotLineStyle() {
return String.format("lt %s dt %s ", //
color.getColor(), //
private String asGnuplotLineStyle(final String colorHex) {
return String.format("lt rgb \"#%s\" dt %s ", //
colorHex, //
dashType.toGnuplotDashType()//
);
}
public String asGnuplotLineStyleBright() {
return asGnuplotLineStyle(color.getBright());
}
public String asGnuplotLineStyle() {
return asGnuplotLineStyle(color.getColor());
}
public String asGnuplotLineStyleDark() {
return asGnuplotLineStyle(color.getDark());
}
@Override
public String toString() {
return asGnuplotLineStyle();
}
public LineStyle brighter() {
return new LineStyle(color.brighter(), dashType);
}
public LineStyle darker() {
return new LineStyle(color.darker(), dashType);
}
}