proplot
proplot copied to clipboard
Error applying individual colors to ax.scatter points
Description
When applying a list of matplotlib-valid colors to an ax.scatter plot, the process fails with a TypeError - it appears to occur when calling numpy to mask values.
Steps to reproduce
A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you.
import proplot as pplt
f, ax = pplt.subplots()
ax.scatter(list(range(5)), [x*2 for x in range(5)], c=['r' for x in range(5)])
Expected behavior: Plot of five red points to appear.
Actual behavior: Process fails with traceback.
Traceback (most recent call last):
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3397, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-90e3e5d9f3e6>", line 1, in <cell line: 1>
ax.scatter(np.arange(5), np.arange(5) * 2, c=['r' for i in np.arange(5)])
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/internals/process.py", line 284, in _redirect_or_standardize
return func(self, *args, **kwargs) # call unbound method
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/axes/plot.py", line 3259, in scatter
return self._apply_scatter(*args, **kwargs)
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/axes/plot.py", line 3220, in _apply_scatter
cc, kw = self._parse_color(
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/axes/plot.py", line 2082, in _parse_color
kwargs = self._parse_cmap(
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/internals/warnings.py", line 96, in _deprecate_kwargs
return func_orig(*args, **kwargs)
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/axes/plot.py", line 2645, in _parse_cmap
vmin, vmax, kwargs = self._parse_vlim(
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/axes/plot.py", line 2158, in _parse_vlim
imin, imax = process._safe_range(z, pmin, pmax)
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/internals/process.py", line 490, in _safe_range
data, units = _to_masked_array(data)
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/proplot/internals/process.py", line 143, in _to_masked_array
data = ma.masked_invalid(data, copy=copy)
File "/home/bryan/.anaconda3/envs/argo-env/lib/python3.10/site-packages/numpy/ma/core.py", line 2366, in masked_invalid
condition = ~(np.isfinite(a))
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Equivalent steps in matplotlib
Please try to make sure this bug is related to a proplot-specific feature. If you're not sure, try to replicate it with the native matplotlib API. Matplotlib bugs belong on the matplotlib github page.
# your code here, if applicable
import matplotlib.pyplot as plt
f, ax = plt.subplots()
ax.scatter(list(range(5)), [x*2 for x in range(5)], c=['r' for x in range(5)])
Proplot version
Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)
here.
3.4.3
0.9.5