How to change data stacking order for a single series in bubble charts?
1 view (last 30 days)
Show older comments
I have a single but large series of xyz data that I want to plot as a bubble chart with bubble colors related to the bubble size values.
However, the plot is not easily readable because the most intense bubbles are hidden by some lower intensity bubbles. How can I change the stacking of the bubbles as a function of bubble size (to plot the most intense bubbles on top of the lowest ones).
Here is a sample code:
figure ;
N = 1e5 ;
x = randn(N,1) ;
y = rand(N,1) ;
z = randi(1e6,[N,1]) ;
[~,edge,idx] = histcounts(z) ;
colors = interp1([min(edge);max(edge)],[1 1 1 ; 0.5 0.5 0.5],edge,"linear","extrap") ;
c = colors(idx,:) ;
figure ;
colormap(c) ;
bubblechart(x,y,z,1:numel(z)) ;
which produces the following output:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1517056/image.png)
0 Comments
Accepted Answer
Star Strider
on 21 Oct 2023
MATLAB plotting functions generally plot in the order specified in the pllotting command, and later objects are plotted ‘on top of’ (for lack of a better description) the objects plotted prior to them. Changing the plotting order could be an option.
2 Comments
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!