How to create hatched fill pattern histograms?

I have to create a plot with two histograms, both normalized through probability, to represent the distribution of an index S in two differenti conditions (a) and (b).
For a better visibility, I would like to add a hatched fill pattern to one of them. Here below there is how the plot looks like without the pattern.

 Réponse acceptée

Setsuna Yuuki.
Setsuna Yuuki. le 22 Nov 2020
Modifié(e) : Setsuna Yuuki. le 22 Nov 2020

0 votes

hello.
You can try with the function in this url:
this is the result:

6 commentaires

How did you manage to make it work for two histograms? Because it did not work with the usual command 'hold on'.
So first you created h1 and h2 like in the example. Then you used the function "applyhatch" specifing h1 and h2 in the input of "applyhatch"?
%Example of mathworks
x = randn(2000,1);
y = 1 + randn(5000,1);
h1 = histogram(x);
hold on
h2 = histogram(y);
h1.Normalization = 'probability';
h1.BinWidth = 0.25;
h2.Normalization = 'probability';
h2.BinWidth = 0.25;
%Applyhatch
applyhatch(gcf,'\x'); %The format for PATTERNS can be
%a string of the characters '/', '\', '|', '-', '+', 'x', '.'
Great. It works nicely once you select a suitable couple of patterns to improve the quallity of visualization. The only issue left is that once the second figure is produced, which is the one with the patterns, I can not find a way to increase the axes fontsize and box width, even opening the 'Property Inspector' window.
If you try it before applying the Applyhatch,maybe it will work.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange

Produits

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by