Git Product home page Git Product logo

Comments (11)

olavolav avatar olavolav commented on May 26, 2024 4

@leighleighleigh Quick update: Inspired by your work, I have started work on this. Check out this branch if you are interested: https://github.com/olavolav/uniplot/tree/os_from_leighleighleighz-datetime_support

It is similar to your approach, but differs in a few areas to keep with uniplot's (as of yet undocumented) design goals:

  1. No additional dependencies, just Python and NumPy
  2. No required configuration, it should "just work". In building uniplot I tried to take on complexity as part of the library, such that the user could just throw data at the plot function and uniplot would figure out the rest.
  3. Nice & friendly axis labels: This is 99% missing right now, I'm just trying to find any date labels right now.

Example of what I have so far:

import numpy as np
dates =  np.arange('2002-10-27T04:30', 4*60, 60, dtype='M8[m]')
plot(xs=dates, ys=[1,2,3,2])

yields:

┌────────────────────────────────────────────────────────────┐
│                                       ▝                    │ 3
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                    ▘                                      ▝│ 2
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│                                                            │
│▖                                                           │ 1
└────────────────────────────────────────────────────────────┘
  04:52:21.900   05:37:27.300   06:22:32.700   07:07:38.100

I'll update this thread as work progresses.

from uniplot.

leighleighleigh avatar leighleighleigh commented on May 26, 2024 2

Just checked it out - looks great! The auto-scaling axis labels are really nice.
Have confirmed our test suite still runs perfectly fine with this new version, too.
uniplot has been fantastic for understanding our unit-test failures by the way, many thanks!

from uniplot.

olavolav avatar olavolav commented on May 26, 2024 2

And we are live as of version v0.12.1 🚀

Thanks everyone for your support and your patience 😄

from uniplot.

olavolav avatar olavolav commented on May 26, 2024 1

Hi @gourisariah that's a good point, indeed plotting data with time stamps and/or categorical data would be great.

I suppose a simple workaround for now would be to ask the users to map the timestamps to "number of day since X" or similar before plotting. But I agree with you that what you showed would be much nicer.

I'll think about it, and will also refresh my memory on how matplotlib and other plotting libraries handle this.

Can't promise anything right now, but I'll look into it. Thanks for the input! 😄

from uniplot.

ryanwwest avatar ryanwwest commented on May 26, 2024 1

Adding my vote for this. Using datetime.datetime would helpful tons of data visualizations.

from uniplot.

leighleighleigh avatar leighleighleigh commented on May 26, 2024 1

I've got a proof-of-concept implementation of this here, which I haven't PR'd due to it being tangled up with other changes.
I'd appreciate your thoughts on it, @olavolav - it feels a little hacky to me, but it does work :)

from uniplot.

 avatar commented on May 26, 2024

Sure @olavolav. That would be great! Thanks a lot.

from uniplot.

olavolav avatar olavolav commented on May 26, 2024

Awesome, thanks @leighleighleigh ! I will have a detailed look once I had a bit more time.

from uniplot.

olavolav avatar olavolav commented on May 26, 2024

@leighleighleigh I've opened a pull request with a first working version, feel free to check it out and let me know what you think.

from uniplot.

olavolav avatar olavolav commented on May 26, 2024

Just keeping this open until the feature is complete

from uniplot.

olavolav avatar olavolav commented on May 26, 2024

Just for the record, I wanted to see how the original request from 2021 would look like now. Taking the stock price of Meta from Yahoo as a CSV, we have:

data = pd.read_csv("META.csv")
data["Timestamp"] = pd.to_datetime(data["Date"])
plot(xs=data.Timestamp, ys=data.Close, title="Meta stock price", y_unit=" $", lines=True)

which yields

                       Meta stock price
┌────────────────────────────────────────────────────────────┐
│                                                           ▐│
│                                                           ▞│
│                                                           ▌│ 400 $
│                                              ▗▖           ▌│
│                                              ▌▌          ▐ │
│                                             ▞ ▚▞▖      ▗ ▛ │
│                                         ▗  ▐    ▌      ▞▞▘ │ 300 $
│                                         ▐▙▜▞    ▌     ▗▘   │
│                                         ▌ ▝▘    ▌     ▞    │
│                                        ▞        ▜▖    ▌    │
│                           ▖▗ ▟   ▐▟▚▐▀▙▘         ▜   ▐     │ 200 $
│                         ▗▀▝▘▛ ▀▖▐▞▘ ▘ ▝           ▙▖ ▞     │
│                     ▄▖▗▀▀      ▝▌                  ▙▗▘     │
│                 ▄▚▀▀ ▝▘                            ▐▛      │ 100 $
│          ▗▄▄▄▄▀▀                                   ▝       │
│      ▄▄▀▀▘                                                 │
│▙▄▄▄▄▞▘                                                     │
└────────────────────────────────────────────────────────────┘
  2013    2014   2016    2017   2019    2020   2021    2023

There is room for improvement, but it works for the moment, I would say.

from uniplot.

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.