Menu

color bar with the same spacing

l1q1d
2017-05-02
2017-05-02
  • l1q1d

    l1q1d - 2017-05-02

    Is there any way to create a color bar with the same spacing but with labels not value spaced equally? (picture as example)

     
  • l1q1d

    l1q1d - 2017-05-03

    Solved using:

    void colorbar_label( PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data  )
    {
    
        PLFLT * inputdata = (PLFLT *) data;
        snprintf( label, length, "%.2f", inputdata[(int)value] );
    }
    ....
    
        const char *axis_opts[] = {
            "uwxno",
        };
    
    PLFLT       shedge[]    = {0.4,1,2,4,10,20,40,100};
    
    num_values[0] = 8;
    
        values[0]     = new PLFLT[ns];
    
        for (int i=0;i<ns;i++){
            values[0][i] = i;
    
        }
           pls->colorbar( &colorbar_width, &colorbar_height,
                       PL_COLORBAR_SHADE | PL_COLORBAR_SHADE_LABEL | PL_COLORBAR_BACKGROUND, PL_POSITION_BOTTOM ,
                       0.0, 0.45,0.9,0.1, 0, 1, 1, 0.0, 0.0,
                       cont_color, 2,
                       n_labels, label_opts, labels,
                       n_axis_opts, axis_opts,
                       axis_ticks, axis_subticks,
                       num_values, values ); 
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.