Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

featurerequest: widget.cartesian - multiple line-plots in same axis #63

Open
5 tasks
s-light opened this issue Dec 16, 2021 · 3 comments
Open
5 tasks

Comments

@s-light
Copy link
Contributor

s-light commented Dec 16, 2021

i think it would make a nice addition to be able to plot multiple lines in the same Cartesian.

what i think needs to be done for this:

  • extract line drawing to sub-class
    • the subclass could be an self contained bitmap or group (what makes more sense here?)
    • change to add point function
    • add draw or update function (what is the better naming here?)
    • color option
  • handle multiple Plot-Classes

please let me know what you think!

This was referenced Dec 16, 2021
@kmatch98
Copy link
Contributor

kmatch98 commented Feb 13, 2022

I’m considering the requested updates to the Cartesian widget. Main updates are to allow for multiple lines to be drawn but also a few more things I’ve got in mind:

  • Multiple individual lines
  • Line color
  • Getters/setters to add or remove lines
  • Option to add/remove single points from lines
  • Option to autoscale if an input to x-range or y-range is None (lower, upper or both ends)

I am considering updating this to use vectorio rather than the current version that draws on a bitmap. I’m unsure if that will save RAM, likely will depend upon how many points and lines are included.

Some initial thoughts on the implementation:

  • Line data uses a new Class

    • linetype: “points” (for future expansion to include “function”s)
    • points: List of (x,y) tuples
    • color: int
    • marker, markersize: (future extension) to include a marker at each point
    • stroke: (future extension) line width, in pixels
    • visible: (future extension) whether line should be displayed
  • Has class functions to return a vectorio representation given an x,y range.

  • Include an _update function:

    1. If auto range is selected with None, calculate the graph’s x and y range.
    2. Create axes, tick marks and tick labels.
    3. For each set of line points, create vectorio lines, truncating them at the edge of the graph range.
    4. (Future extension) Add markers.

@jposada202020
Copy link
Contributor

@s-light and @kmatch98 Interesting, Love the ideas. We start to play with Vectorio in CP 7.0 If memory is accurate, and the development of this library was done on CP 6.XX. We played with some of @s-light ideas in these libraries that could that could improve the library. https://github.com/jposada202020/CircuitPython_ArrowLine and https://github.com/jposada202020/CircuitPython_Candlesticks. Anyway sorry for the late answer. @kmatch98 You know more about memory than me for sure :) so any advice is welcome :)

Also there was this https://github.com/romilly/microplot project that could help as inspiration.

@jposada202020
Copy link
Contributor

Hello, again :)

I have revisiting again this. Went in a completely different direction. I wanted to add different elements on the plot, including the vectorio, and adafruit_display_shapes library. see my progress here
https://github.com/jposada202020/CircuitPython_uplot

Take a look to the capabilities here, including adding different graphs in the same plot_area
https://circuitpython-uplot.readthedocs.io/en/latest/examples.html

Not sure if we want to add more features!?. For example the fesature to draw under the curve done by @tekktrik was pr in CircuitPython_Org and not here. I would continue the work in uplot and releasing the library in the community bundle if anyone is interested. Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants