Comments (6)
Hi Enrico, this should already be supported in both proplot/matplotlib. It's kind of weird to wrap your head around, but basically numpy supports defining "ragged" nested arrays where each object is itself a 1D array. In your example, the idea would be to define a 3-element array, each of which contains a tuple from your list. Works as follows:
data = np.array([(2, 3, 4), (1, 2), (1, 2, 3, 4, 5, 6, 7)], dtype=object)
fig, ax = pplt.subplots()
ax.boxplot(data)
Also simply passing your nested list to ax.boxplot()
without the np.array(..., dtype=object)
should work, but may raise the following warning (may try to suppress this warning in future versions):
/Users/ldavis/mambaforge/lib/python3.10/site-packages/numpy/core/shape_base.py:65:
Creating an ndarray from ragged nested sequences (which is a list-or-tuple
of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated.
If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
from proplot.
Thanks for the answer. I tried the code you provided:
data = np.array([(2, 3, 4), (1, 2), (1, 2, 3, 4, 5, 6, 7)], dtype=object)
fig, ax = pplt.subplots()
ax.boxplot(data)
but it yields the error:
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''
Is it a problem only on my side?
from proplot.
Hmm I think you might be using an older version? What does print(pplt.__version__)
show? You can install the "dev" version (includes newest/unreleased changes) using pip install git+https://github.com/proplot-dev/proplot.git
.
from proplot.
my version was 0.9.7. Now I installed the dev version and it shows that it's version 0.9.5.post358 (is it expected that the version number is lower in a dev install?). When I run the same code, now I get an exception from function_base.py of numpy:
_4559 def _lerp(a, b, t, out=None):
4560 """
4561 Compute the linear interpolation weighted by gamma on each point of
4562 two same shape array.
(...)
4571 Output array.
4572 """
-> 4573 diff_b_a = subtract(b, a)
4574 # asanyarray is a stop-gap until gh-13105
4575 lerp_interpolation = asanyarray(add(a, diff_b_a * t, out=out))TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'_
from proplot.
Yeah in this case -- 0.9.7
is built from a separate branch off of the 0.9.5
commit, it doesn't live on the main branch. You still have the latest version -- 0.9.7
is equivalent to 0.9.5
, but enforces a maximum matplotlib version when you install.
It looks like this is a bug in your function. Add a = np.asarray(a)
and b = np.asarray(b)
in the first two lines of your function. Let me know if you have any other proplot-specific issues.
from proplot.
Related Issues (20)
- unexpected minor ticks in colorbar
- Hide datetime minorticks?
- Feature request: allow a single label for a group of lines HOT 4
- add more color blind-friendly default color cycle
- bug: cannot set equal aspect for log scale HOT 1
- How to set the order of 'abc'? HOT 1
- Bug: xticklabels overwrites xminorticks setting HOT 3
- Cannot pass norm argument to hist2d
- Any timeline for a relase that supports matplotlib >=3.5?
- Proplot changes names of colormaps to lowercase, breaking `matplotlib.pyplot.get_cmap`
- MatplotlibDeprecationWarning with unexpected argument for savefig() HOT 3
- proplot can't plot string like datetime
- Inset_axes zooms doesn't show lines
- Trying to make a line over contourf returns TypeError HOT 5
- TypeError: tricontourf() takes 4 positional arguments but 5 were given
- Option for adding errorbar legend
- Nonsticky bounds
- How to use proplot in MATLAB HOT 1
- path effects not pretty
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proplot.