GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Plot frame by kushalkolar · Pull Request #313 · fastplotlib/fastplotlib

Conversation

@kushalkolar

@kushalkolar kushalkolar commented Oct 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

closes #310 closes #342 closes #268

This PR adds a Frame class that manages how plots are shown. Plot and Gridplot, and any future flexilbe gridplot, inherit from Frame.

How this works:

Toolbars

Refactored ipywidget Toolbar that is common between Plot, Gridplot and any future gridplots

Output Contexts

These are classes that "hold" the output of a Plot/Gridplot. They determine how the canvas, toolbar, and any additional widgets are shown. When Plot.show() is called, they return an instance of one of the following output contexts based on the curent plot canvas.

  • JupyterOutputContext
    • Inherits from ipywidgets.VBox and contains the canvas, toolbar, and any other widgets. Manages sidecar if desired.
  • QOutputContext
    • Inherits from QWidget, contains the canvas, qt toolbar, and any other widgets.
  • If the canvas is not jupyter or qt (ex. if it's glfw or offscreen like in our test suite), the output context is just the plot canvas itself.

This cleans up the messy show() calls we previously had everywhere, and cleans up other stuff too. Now the output context manages closing plots too.

BTW, the QOutputContext can also be used in notebooks with if you execute %gui qt before creating plots 😄

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@clewis7

clewis7 commented Oct 3, 2023

Copy link
Copy Markdown
Member

#310

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7 clewis7 mentioned this pull request Oct 11, 2023
manual annotation of ethograms hantman-lab/animal-soup#60
Merged
@kushalkolar kushalkolar mentioned this pull request Sep 24, 2023
Roadmap Fall 2023 #130
Closed
16 of 17 tasks
This was referenced Oct 25, 2023
add polygon button to gridplot toolbar #334
Merged
make sidecar=False the default? #342
Closed
@kushalkolar
WIP on plot frame
88f33c3
@kushalkolar
kushalkolar force-pushed the plot-frame branch from 0d6b766 to 88f33c3 Compare October 29, 2023 20:47
@kushalkolar
kushalkolar marked this pull request as ready for review October 29, 2023 20:48
kushalkolar added 2 commits October 29, 2023 19:01
@kushalkolar
create Output context classes, basic layout of Frame, not tested yet
34ff9a2
@kushalkolar
plot frame system working for jupyter
80a3fb2
@kushalkolar

kushalkolar commented Oct 29, 2023

Copy link
Copy Markdown
Member Author

This is working now with JupyterOutputContext! Also fixed the wonky issue with auto-scale and center scene when you had a single controller controlling multiple cameras for diff subplots.

Now onto Qt output context and toolbar.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 10 commits October 29, 2023 21:06
@kushalkolar
make it work with imagewidget
7943697
@kushalkolar
update demo nbs
57e0fe9
@kushalkolar
fix finding if imagegraphic is present
4c0002b
@kushalkolar
fix finding images again
dbcedf8
@kushalkolar
update desk image screenshots
9c222dd
@kushalkolar
update screenshot
6dd2f1a
@kushalkolar
qt works with toolbar
5e11f87
@kushalkolar
qt context works with image widget
6da3517
@kushalkolar
comments
b1e7bda
@kushalkolar
bugfix with flipping
81df69f
@kushalkolar

kushalkolar commented Oct 30, 2023

Copy link
Copy Markdown
Member Author

Everything works on my end, I tested every combination with ipywidgets, sidecar/no sidecar, Qt, and with ImageWidget.

Right now the toolbar implementations are quite repetitive, we can make that nicer in a future PR after we have some time to think about it. Someone must have made a common interface between ipywidgets and Qt that we can use.

qt.mp4
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clewis7
clewis7 reviewed Oct 30, 2023
View reviewed changes
Comment thread fastplotlib/layouts/_frame/_frame.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_frame/_frame.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_frame/_ipywidget_toolbar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_frame/_ipywidget_toolbar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_frame/_jupyter_output.py
self.output = (frame.canvas, *add_widgets)

if make_toolbar: # make toolbar and stack canvas, toolbar, add_widgets
self.toolbar = IpywidgetToolBar(frame)

@clewis7 clewis7 Oct 30, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if ImageWidget? where is logic for if plot type is imagewidget?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kushalkolar kushalkolar Oct 30, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImageWidget just uses the Gridplot context:

    def show(self, toolbar: bool = True, sidecar: bool = False, sidecar_kwargs: dict = None):
        """
        Show the widget

        Returns
        -------
        OutputContext
        """
        if self.gridplot.canvas.__class__.__name__ == "JupyterWgpuCanvas":
            self._image_widget_toolbar = IpywidgetImageWidgetToolbar(self)

        elif self.gridplot.canvas.__class__.__name__ == "QWgpuCanvas":
            self._image_widget_toolbar = QToolbarImageWidget(self)

        return self.gridplot.show(
            toolbar=toolbar,
            sidecar=sidecar,
            sidecar_kwargs=sidecar_kwargs,
            add_widgets=[self._image_widget_toolbar]
        )

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@clewis7

clewis7 commented Oct 30, 2023

Copy link
Copy Markdown
Member

did you update the requirements file?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Oct 30, 2023

Copy link
Copy Markdown
Member

Another thing I see is that when I have two subplots in an imagewidget and the camera y_scales are opposite that when I change click between subplots the flip button is not changing in accordance with the camera y_scale...just stays the same

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Oct 30, 2023

Copy link
Copy Markdown
Member Author

did you update the requirements file?

No dependency changes here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Oct 30, 2023

Copy link
Copy Markdown
Member Author

Another thing I see is that when I have two subplots in an imagewidget and the camera y_scales are opposite that when I change click between subplots the flip button is not changing in accordance with the camera y_scale...just stays the same

In ipywidgets or Qt?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Oct 30, 2023

Copy link
Copy Markdown
Member

Another thing I see is that when I have two subplots in an imagewidget and the camera y_scales are opposite that when I change click between subplots the flip button is not changing in accordance with the camera y_scale...just stays the same

In ipywidgets or Qt?

ipwidgets

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@clewis7

clewis7 commented Oct 30, 2023

Copy link
Copy Markdown
Member

did you update the requirements file?

No dependency changes here.

not even if someone only wants qt? they would need to have pyqt6 installed right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Oct 30, 2023

Copy link
Copy Markdown
Member Author

did you update the requirements file?

No dependency changes here.

not even if someone only wants qt? they would need to have pyqt6 installed right?

Qt land is a bit complicated, so they will have to install Qt themselves separately. We can do toggles later, because to do this properly we need to give users the option of PySide etc and decide how broad we want this support.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar
remove junk files
6f85ced
@kushalkolar

kushalkolar commented Oct 31, 2023

Copy link
Copy Markdown
Member Author

Another thing I see is that when I have two subplots in an imagewidget and the camera y_scales are opposite that when I change click between subplots the flip button is not changing in accordance with the camera y_scale...just stays the same

In ipywidgets or Qt?

ipwidgets

I think now I see what you mean, it is wonky! So this is because in ImageWidget all cameras are under one controller. I did not decide how to deal with flipping when controllers are diff. What I will do is if the flip button is clicked, it will flip the camera for the current subplot but also any camera that has the same controller (similar to what I did for panzoom and maintain_aspect).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar added 8 commits October 30, 2023 20:33
@kushalkolar
fix flip, image widget can reset vmin vmax based on currently display…
5bed8a1
…ed frame
@kushalkolar
hlut autoscales plot area when set_data() called
45a752e
@kushalkolar
return buffer
2b276a5
@kushalkolar
reset hlut button
232e902
@kushalkolar
add reset hlut button to QToolbar
ae9b47e
@kushalkolar
add wiget property to imagewidget, fix gridplot kwargs handling
3cfe184
@kushalkolar
qt toolbar layouting
059cb9f
@kushalkolar
add standalone qt image widget example
3c9f4a9
@kushalkolar
kushalkolar merged commit 932454f into main Oct 31, 2023
@kushalkolar kushalkolar mentioned this pull request Oct 31, 2023
Embedding in PyQt #340
Closed
@kushalkolar
kushalkolar deleted the plot-frame branch October 31, 2023 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@clewis7 clewis7 clewis7 left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

make sidecar=False the default? make a PlotFrame class for Toolbar and sidecar functionality Setting the coordinate reference system

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kushalkolar @clewis7
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.