Skip to content
Advertisement

How to convert a ordinal color to linear color heatmap in Anychart?

Today I was trying to create a 2d heatmap plot using Anychart libraries in android studio. I am unable to convert ordinalcolor to linearcolor. Can someone please help me on this.
Short info:
Setting up the gradle in Android studio:

allprojects {
repositories {
    google()
    jcenter()
    maven { url 'https://jitpack.io' }
}

}

dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.AnyChart:AnyChart-Android:1.1.2'

Heatmap creation:

    HeatMap heatmaps = AnyChart.heatMap();
    List<DataEntry> data = new ArrayList<>();

Heatmap data Entry:

        for (int i = 0; i < 1; i++) {
        for (int j = 0; j < nx; j++) {
            for (int k = 0; k < nx; k++) {
                data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
            }
        }
    }

Final plot:

   String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
   heatmaps.colorScale().colors(strArray3);
   heatmaps.data(data);
   AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
   anyChartView.setChart(heatmaps);

Result_heatmap_view

How can i get rid of the white spaces between each color block?
Thank you for your help.
Complete code:

        int nx=100;
    int[][][] Pressure=new int[1][nx][nx];
    for (int i=0;i<1;i++) {
        for (int j=0;j<nx;j++) {
            for (int k=0;k<nx;k++) {
                Pressure[i][j][k] = 50;
            }
        }
    }

    for (int i=0;i<1;i++) {
        for (int j=nx/2-5;j<=nx/2+5;j++) {
            for (int k=nx/2-5;k<=nx/2+5;k++) {
                Pressure[i][j][k] = 20;
            }
        }
    }
    for (int i=0;i<1;i++) {
        for (int j=nx/2-3;j<=nx/2+3;j++) {
            for (int k=nx/2-3;k<=nx/2+3;k++) {
                Pressure[i][j][k] = 2;
            }
        }
    }


    HeatMap heatmaps = AnyChart.heatMap();
    List<DataEntry> data = new ArrayList<>();

    for (int i = 0; i < 1; i++) {
        for (int j = 0; j < nx; j++) {
            for (int k = 0; k < nx; k++) {
                data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
            }
        }
    }
    String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
    heatmaps.colorScale().colors(strArray3);
    heatmaps.data(data);
   AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
   anyChartView.setChart(heatmaps);

Advertisement

Answer

Currently Anychart does not have the capability to use linear color in Heat map so we can use,

HeatMap heatmaps = AnyChart.heatMap();
heatmaps.stroke("none");  

To remove the white strokes between the colors.
Source: Anychart support

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement