Skip to content

Categorical data (and BarWidth Name-Value Argument) not supported in histogram() #198

Closed
@xarico10

Description

@xarico10

When using categorical data on histogram an error is being printed.

A = [0 0 1 1 1 0 0 0 0 NaN NaN 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1];
C = categorical(A,[1 0 NaN],{'yes','no','undecided'});

histogram(C,'BarWidth',0.2);

fig2plotly();

The previous code prints the following error:

Error using response_handler (line 31)
Expecting (x, y) pairs

Error in makecall (line 32)
    response_handler(resp);

Error in plotly (line 28)
response = makecall(args, origin,
structargs);

Error in plotlyfig/plotly (line 437)
            args.layout = obj.layout;

Error in fig2plotly (line 49)
p.plotly;

Error in A_histogram (line 49)
fig2plotly();

Expected plot:
Captura de Pantalla 2021-07-26 a la(s) 11 19 07 p  m

As the Name-Value argument 'BarWidth' only works for categorical histograms, this also leads to a disfunction with this argument.

Examples on using categorical data with histogram() can be found on:
https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.primitive.histogram.html#buy5k3l

Metadata

Metadata

Labels

⭐⭐⭐ multiplierIssues that could close multiple related issues at once

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions