How to edit histograms?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bora Semiz
am 15 Jan. 2014
Beantwortet: Bora Semiz
am 17 Jan. 2014
Hello guys! I have Data Mining class and in order to prepare my report I have to know more about histograms.
I have a file, which I attach this thread, showing a log which belongs to a phone company. The last column ("churn") indicates that if the user resigned from the operator or not. My mission is to find interesting relationships showing why user have resigned from the operator. For example, I choose one of the columns (e.g Day Mins) and examine it. If people who has lots of day mins tend to resign, I have to prove this.
I want to plot an histogram for indicating that. I have the information of who has resigned or not as true or false values. So how can I split each bar into two bars. A single bar will contain two bars. One bar at the down is people who have resigned and the other bar at the top will be the people who did not resign. In attachment I also giving you the plot that I made.
0 Kommentare
Akzeptierte Antwort
AJ von Alt
am 17 Jan. 2014
If I understand you correctly you want a histogram that looks like this:
This can be achieved by using hold to overlay the resigned histogram over the total histogram.
To do so plot your first histogram:
bar( centers , n , 'b' )
Turn on hold to prevent overwriting the first histogram:
hold on
Plot your second histogram:
bar( centers , n2 , 'r' )
Finally, turn off hold when your are done:
hold off
The following code gives you an example for two randomly generated data sets dayMinsUnresigned and dayMinsResigned. To use this code with your data you will first have to sort dayMins into the two vectors. Logical indexing would be a good place to get started with that.
%Inputs
dayMinsUnresigned = 10*rand(1 , 100);
dayMinsResigned = 10*rand(1 , 100);
%Histogram for each input using the same centers
[nUnresigned , minuteCenters] = hist( dayMinsUnresigned );
nResigned = hist( dayMinsResigned, minuteCenters );
%Sum the bins so that the second data set appears above the first
nSum = nUnresigned + nResigned;
figure;
bar(minuteCenters , nSum , 'b' ) %create the total histogram
% turn on hold so you can add another histogram to the same axis
hold on
bar(minuteCenters , nResigned , 'r' )
% do not forget to turn off hold when you're done!
hold off
legend('Not Resigned' , 'Resigned' )
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!