Skip to content

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

Open
@s-light

Description

@s-light
Contributor

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!

Activity

kmatch98

kmatch98 commented on Feb 13, 2022

@kmatch98
Contributor

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

jposada202020 commented on Jan 20, 2023

@jposada202020
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

jposada202020 commented on Feb 11, 2023

@jposada202020
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @s-light@kmatch98@jposada202020

        Issue actions

          featurerequest: widget.cartesian - multiple line-plots in same axis · Issue #63 · adafruit/Adafruit_CircuitPython_DisplayIO_Layout