Code Monkey home page Code Monkey logo

Comments (6)

lukelbd avatar lukelbd commented on June 4, 2024

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)

iTerm2 vZHqwd tmphwb419q8

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.

reemagit avatar reemagit commented on June 4, 2024

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.

lukelbd avatar lukelbd commented on June 4, 2024

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.

reemagit avatar reemagit commented on June 4, 2024

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.

lukelbd avatar lukelbd commented on June 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.