You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand, heatmap should look like this:
In other words, the xAxis and yAxis should be as CategoryAxis or something (the x and y ticks should be in the middle or each square).
But in this example, the xAxis and yAxis are DefaultNumericAxis, so the x and y ticks are not in the middle.
So I change them to CategoryAxis:
List<String> xCategories = new ArrayList<>();
for (int i = 0; i < 16; i++) {
xCategories.add(String.valueOf(i));
}
final CategoryAxis xAxis = new CategoryAxis("X Position");
xAxis.setCategories(xCategories);
final CategoryAxis yAxis = new CategoryAxis("Y Position");
yAxis.setCategories(xCategories);
final DefaultNumericAxis zAxis = new DefaultNumericAxis();
zAxis.setAnimated(false);
zAxis.setAutoRangeRounding(false);
zAxis.setName("z Amplitude");
zAxis.setAutoRanging(true);
zAxis.setSide(Side.RIGHT);
zAxis.getProperties().put(Zoomer.ZOOMER_OMIT_AXIS, true);
final XYChart chart = new XYChart(xAxis, yAxis);
chart.getAxes().add(zAxis);
chart.setTitle("Test data");
chart.setAnimated(false);
chart.getRenderers().clear();
chart.setLegendVisible(false);
final ContourDataSetRenderer contourRenderer = new ContourDataSetRenderer();
contourRenderer.getAxes().addAll(xAxis, yAxis, zAxis);
chart.getRenderers().setAll(contourRenderer);
contourRenderer.setContourType(colorMap); // false: for color gradient map, true: for true contour map
// contourRenderer.getDatasets().add(readImage());
contourRenderer.getDatasets().add(createTestData());
public DataSet createTestData() {
double[] xValues = new double[16];
double[] yValues = new double[16];
double[] zValues = new double[16 * 16];
for (int i = 0; i < 16; i++) {
xValues[i] = i;
}
for (int i = 0; i < 16; i++) {
yValues[i] = i;
}
Random random = new Random();
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
zValues[i * 16 + j] = random.nextInt(1, 16);
}
}
return new DataSetBuilder("contour data").setValues(DataSet.DIM_X, xValues).setValues(DataSet.DIM_Y, yValues).setValues(DataSet.DIM_Z, zValues).build();
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As I understand, heatmap should look like this:
In other words, the xAxis and yAxis should be as CategoryAxis or something (the x and y ticks should be in the middle or each square).
But in this example, the xAxis and yAxis are DefaultNumericAxis, so the x and y ticks are not in the middle.
So I change them to CategoryAxis:
It is still not what I want:
So what should I do?
Beta Was this translation helpful? Give feedback.
All reactions