How to generate a pareto plot with an ordered X-axis?

9 views (last 30 days)
Matthew
Matthew on 11 Oct 2025 at 22:17
Answered: dpb on 12 Oct 2025 at 18:32
Hello,
I'm looking to organize my data into a plot similar to a pareto plot, but I want the x-axis to be in ascending order from zero like a normal scatter plot. Another way to describe what I am looking for is a histogram (where the x-axis is various buckets of values) but with the y-axis being the sum of the values in each bucket instead of occurences.
I attached some of my data, basically I want to be able to plot frequency on the x-axis, and the sum of column B on the Y axis. Column C is a running sum of Column B, and its basically this data that I want to see in bar form.
Is there a way I can modify the pareto or histogram functions to do what I want or do I need to do something from scratch?
Any insight would be appreciated.
Thanks,
Matt

Answers (1)

dpb
dpb ungefär 7 timmar ago
xyz=readmatrix('sample_data1.csv');
whos xyz
Name Size Bytes Class Attributes xyz 61x3 1464 double
xyz(1:10,:)
ans = 10×3
184.2248 0.2222 0.2222 187.2484 0.0075 0.2296 192.4868 0.0000 0.2297 201.2158 0.0000 0.2297 225.6160 0.0000 0.2297 230.3885 0.0019 0.2316 238.8880 0.0000 0.2316 263.4815 0.0012 0.2328 265.9375 0.0040 0.2368 291.1873 0.0101 0.2469
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
numel(unique(xyz(:,1))) % how many unique values of first column are there?
ans = 61
Well, they're all unique.
I'm not at all sure what, specifically, you envision the plot to be or how to interpret "plot frequency on the x-axis". What does "frequency" mean here?
One guess would be simply
bar(xyz(1:10:end,1),xyz(1:10:end,3))
that assumes equal number of rows/bin and the associated cumulative total at that bin location. One could even out the x-spacing by using
[~,edges,bin]=histcounts(xyz(:,1),nbins);
and use the last element of each bin edges to get the x-position associated with the bin to get the accumulated total for the bin.
I don't believe you could make the Pareto plot do anything like you want; it computes the distribution from the inputs regardless, you cannot change its internal interpretation of what the data represent.

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!