Bar Graph Colors in GUI
이전 댓글 표시
I have a GUI (made with GUIDE) that has a set of axes and some radio buttons. When it open it loads some data and pressing the radio buttons will plot the data in different ways (mean, standard deviation, histogram). I plot the histogram using the bar() command, and I put in a matrix of data where each column is data from a different day.
When the first plot I select to be displayed is the histogram, the colors come up correctly where the data from each column has its own color. The same happens when I just open up a new figure and pass the data into bar(). If I select one of the other plots first (mean, standard deviation), which just does a plot(), and then flip back to histogram then all the bars come up with the same color.
The code I use to plot (in the function update_plot()):
axes(handles.axes1);
bar(t,hist_data);
legend(legends);
where t is a vector of bin centers and hist_data is a matrix of the histogram values in each bin (rows) by the multiple days (columns) data was loaded from.
I have tried digging through the axes handles to see if there was an obvious parameter that was set wrong, but I couldn't spot anything.
The GUI and some dummy data is attached in a .zip file.
댓글 수: 4
Geoff Hayes
2016년 10월 18일
Kris - you may need to attach your GUI or at least a small working sample that exhibits this behaviour so that we can see exactly what the code is doing.
Kris
2016년 10월 18일
Image Analyst
2016년 10월 18일
histogram() no longer does histograms by columns like it sued to do in older versions. It takes the histogram of the entire array. (I didn't download your code so I'm not sure if you used that or histcounts or hist or histc.)
Kris
2016년 10월 18일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!