alandefreitas / matplotplusplus

Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
https://alandefreitas.github.io/matplotplusplus/
MIT License
4.11k stars 313 forks source link

Stacked bar fails if more series than categories #310

Open jl-2021 opened 1 year ago

jl-2021 commented 1 year ago

Bug category

Describe the bug mp::barstacked(Y) fails if no. stacked series > no. x axis categories.

Steps to Reproduce

include "matplot/matplot.h"

namespace mp = matplot; int main() {

mp::figure(true);
mp::subplot(1, 1, 0);
mp::hold(mp::on);

std::vector<double> x{0.1,0.2,0.3};
std::vector<std::vector<double>> y;
int J{4};        //More generally, run if 0<J<=x.size() but fails otherwise
for (int j=0; j<J; ++j) { 
    y.push_back(x);
}
mp::barstacked(y);
mp::show();

return 0;

}

Output

Runtime error

Runtime error msg:
test_plot: malloc.c:2617: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

Platform

Environment Details:

Additional context matplotplusplus dependency included with these CMake commands:

include(FetchContent) FetchContent_Declare(matplotplusplus GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus GIT_TAG origin/master) # or whatever tag you want FetchContent_GetProperties(matplotplusplus)

navidkpr commented 1 year ago

Not having this issue on MacOs Ventura