how to create histogram

3 visualizzazioni (ultimi 30 giorni)
Junaid Ahmed
Junaid Ahmed il 8 Lug 2021
Commentato: Junaid Ahmed il 9 Lug 2021
you can take any value of density just i wanna know to how to creat histogram of density
Each plot has different customization options.
Try creating a histogram of density with the histogram function.
Set the "FaceColor" to yellow ("y").

Risposta accettata

DGM
DGM il 8 Lug 2021
Modificato: DGM il 8 Lug 2021
density = randn(100);
h = histogram(density);
h.FaceColor = 'y';
% if you want to set other properties, take a look
get(h)
Annotation: [1×1 matlab.graphics.eventdata.Annotation] BeingDeleted: off BinCounts: [2 3 3 11 11 20 39 45 101 130 186 231 331 425 529 587 710 758 830 810 798 691 617 536 433 341 239 207 141 80 60 44 19 12 10 3 3 3 0 1] BinCountsMode: 'auto' BinEdges: [1×41 double] BinLimits: [-3.8000 4.2000] BinLimitsMode: 'auto' BinMethod: 'auto' BinWidth: 0.2000 BusyAction: 'queue' ButtonDownFcn: '' Children: [0×0 GraphicsPlaceholder] ContextMenu: [0×0 GraphicsPlaceholder] CreateFcn: '' Data: [100×100 double] DataTipTemplate: [1×1 matlab.graphics.datatip.DataTipTemplate] DeleteFcn: '' DisplayName: '' DisplayStyle: 'bar' EdgeAlpha: 1 EdgeColor: [0 0 0] FaceAlpha: 0.6000 FaceColor: [1 1 0] HandleVisibility: 'on' HitTest: on Interruptible: on LineStyle: '-' LineWidth: 0.5000 Normalization: 'count' NumBins: 40 Orientation: 'vertical' Parent: [1×1 Axes] PickableParts: 'visible' Selected: off SelectionHighlight: on SeriesIndex: 1 Tag: '' Type: 'histogram' UserData: [] Values: [2 3 3 11 11 20 39 45 101 130 186 231 331 425 529 587 710 758 830 810 798 691 617 536 433 341 239 207 141 80 60 44 19 12 10 3 3 3 0 1] Visible: on
% if you're not sure what values are appropriate for certain properties
set(h)
BinCounts: {} BinCountsMode: {'auto' 'manual'} BinEdges: {} BinLimits: {} BinLimitsMode: {'auto' 'manual'} BinMethod: {'auto' 'scott' 'fd' 'integers' 'sturges' 'sqrt'} BinWidth: {} BusyAction: {'queue' 'cancel'} ButtonDownFcn: {} Children: {} ContextMenu: {} CreateFcn: {} Data: {} DeleteFcn: {} DisplayName: {} DisplayStyle: {'bar' 'stairs'} EdgeAlpha: {} EdgeColor: {'auto' 'none'} FaceAlpha: {} FaceColor: {'auto' 'none'} HandleVisibility: {'on' 'callback' 'off'} HitTest: {[on] [off]} Interruptible: {[on] [off]} LineStyle: {'-' '--' ':' '-.' 'none'} LineWidth: {} Normalization: {'count' 'countdensity' 'cumcount' 'probability' 'pdf' 'cdf'} NumBins: {} Orientation: {'vertical' 'horizontal'} Parent: {} PickableParts: {'visible' 'none' 'all'} Selected: {[on] [off]} SelectionHighlight: {[on] [off]} SeriesIndex: {} Tag: {} UserData: {} Visible: {[on] [off]}
% properties can be read/set using get/set
get(h,'FaceColor')
ans = 1×3
1 1 0
set(h,'FaceColor','b')
% or by using dot notation as in the initial example

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by