Repository navigation
Closed
Description
Describe the bug
The example for plot_dist at https://bears-r-us.github.io/arkouda/autoapi/arkouda/plotting/index.html#arkouda.plotting.plot_dist does not work and causes a bug as follows:
To Reproduce
>>> b, h = ak.histogram(ak.arange(10), 3)
>>> ak.plot_dist(b, h.to_ndarray())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lus/scratch/khandeka/arkouda/arkouda/plotting.py", line 50, in plot_dist
plt.plot(b, h, marker=".", linestyle="solid")
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/pyplot.py", line 3794, in plot
return gca().plot(
^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_axes.py", line 1779, in plot
lines = [*self._get_lines(self, *args, data=data, **kwargs)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 296, in __call__
yield from self._plot_args(
^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 481, in _plot_args
axes.xaxis.update_units(x)
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axis.py", line 1750, in update_units
converter = munits.registry.get_converter(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/units.py", line 183, in get_converter
first = cbook._safe_first_finite(x)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/cbook.py", line 1781, in _safe_first_finite
for val in obj:
^^^
File "/lus/scratch/khandeka/arkouda/arkouda/pdarrayclass.py", line 887, in __iter__
raise NotImplementedError(
NotImplementedError: pdarray does not support iteration. To force data transfer from server, use to_ndarrayIf we also convert b to an ndarray as the doc should, we still get a different error:
>>> ak.plot_dist(b.to_ndarray(), h.to_ndarray())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lus/scratch/khandeka/arkouda/arkouda/plotting.py", line 50, in plot_dist
plt.plot(b, h, marker=".", linestyle="solid")
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/pyplot.py", line 3794, in plot
return gca().plot(
^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_axes.py", line 1779, in plot
lines = [*self._get_lines(self, *args, data=data, **kwargs)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 296, in __call__
yield from self._plot_args(
^^^^^^^^^^^^^^^^
File "/lus/scratch/khandeka/anaconda3/envs/arkouda-dev/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 486, in _plot_args
raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (3,) and (4,)Expected behavior
A plot of the distribution and cumulative distribution of the histrogram data
Is this a Blocking Issue
Not blocking
- Are there any known work-arounds? yes
- If a known work around exists, please provide a code block demonstrating it.
We can preprendbwith a0to make the dimensions equal toh:
b = ak.concatenate([ak.array([0]), b])Which then makes the dimensions of b and h equal and generates the plot.
Also we don't need to do plt.show() to show the plot, which is the opposite of what the docs claim.
Activity
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes Bears-R-Us#3942: ak.plot_dist docs example produces an error
Closes #3942 ak.plot dist docs example produces an error (#4868)