Bar Graph Colors in GUI
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Image Analyst
le 18 Oct 2016
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.)
Réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!