How to put a boxplot on a scatterplot/histogram?

15 visualizzazioni (ultimi 30 giorni)
Saar Peles
Saar Peles il 22 Ott 2020
Modificato: Adam Danz il 27 Ott 2020
I'm trying to put a boxplot over the data points in this scatterplot but can't find anything. This is the code to setup the table for the scatterhistogram
tbl = table(swine, cc, depth);
s = scatterhistogram(tbl, 'swine', 'cc', 'GroupVariable', 'depth');
The scatterplot is attached. Many thanks
  5 Commenti
Adam Danz
Adam Danz il 23 Ott 2020
Modificato: Adam Danz il 26 Ott 2020
Yeah, I'm not sure I understand the reasoning behind the family of high-level, standalone visualizations such as scatterhistogram, that mirror other visualization functions but without the same level of customizability.
To make things even more confusing, there are inconsistencies in the param names between the two functions (ie, nbins vs NumBins, which appear to do the same thing).
TMW have made some improvements to the standalone functions, though. I submitted a feature request earlier this year because scatterhistogram wouldn't allow us to add anything to the axes such as yline(),text(), or even a marker to indicate mean/median values using plot(). boxchart() is another example of a standalone version of boxplot() but I recall being able to make these modifications in boxchart. It looks like theses capabilities have been added to scatterhistogram in the r2020b release.
I'm guessing that their motovation is to streamline the use of these functions without the need to manipulate handle properties but if you compare the inputs between the standalone versions and the customizable versions, they aren't that much different. The standalone versons also give TMW greater flexibility in updating the functions without worrying about backward compatibility associated with external property manipulation. Except for the most basic use cases, I bet a lot of newer users eventually migrate their visualization from the standalone versions to the customizable versions as in this thread.
dpb
dpb il 24 Ott 2020
Yeah, seems like they waste a LOT of time on such trivia and neglect far more significant improvements. Meanwhile the code bloat just continues to mutiply.
It certainly is not clear who's driving the ship and where they think they're going.

Accedi per commentare.

Risposte (1)

Adam Danz
Adam Danz il 23 Ott 2020
Modificato: Adam Danz il 27 Ott 2020
scatterhistogram() is its own class and does not provide access to its axes. Instead, use the older scatterhist(). It's output is a 1x3 vector of axis handles where the first handle is the axis to the scatter plot.
h = scatterhist(___);
hold(h(1), 'on')
boxplot(___)
However, the marginal histograms are normalized and the boxplots will likely be at a much larger scale than the histograms. To see the axis scale, turn on the axes using,
axis(h(3), 'on')
I suggest putting the boxplots elsewhere, perhaps in their own axes or within the scatter axes.
  3 Commenti
Saar Peles
Saar Peles il 23 Ott 2020
Modificato: Saar Peles il 23 Ott 2020
I tried something similar but the boxplot wouldn't stay. I asked a previous question about it here: https://www.mathworks.com/matlabcentral/answers/616608-scatterhist-function-not-allowing-for-boxplot-on-the-y-axis-to-stay?s_tid=srchtitle

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by