-
Notifications
You must be signed in to change notification settings - Fork 53
Legend update_using_camera #835
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
base: main
Are you sure you want to change the base?
Conversation
Updated legend color handling and scaling Provided PyQt lineplot example using black on white background
# delete docs/api dir rm -rf docs/source/api # delete _gallery dir rm -rf docs/source/_gallery # regenerate the API docs python docs/source/generate_api.py
Updated legend color handling and scaling Provided PyQt lineplot example using black on white background
# delete docs/api dir rm -rf docs/source/api # delete _gallery dir rm -rf docs/source/_gallery # regenerate the API docs python docs/source/generate_api.py
…stplotlib into legend-pygfx-compat
This looks like a great start! Do you want to implement more of what's in #403 or we'll just use this for now and implement the rest when we can. I have a bunch of changes to make but I think it's easier if I edit your branch directly if you don't mind. |
def update_using_camera(self): | ||
""" | ||
Update the legend position and scale using the camera. | ||
This only works if legend is in a Dock, not a Plot or Subplot. | ||
""" |
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.
This will be much easier after #830 is merged (by tomorrow) since it adds an overlay render pass.
) | ||
|
||
# Subplot | ||
self.ax = self.fig[0, 0] |
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.
let's just call these subplot instead of ax
to conform with the rest of the examples, I can make these changes if you want
def rotate(angle, axis_x, axis_y, axis_z): | ||
""" | ||
Quaternion representing rotation around the given axis by the given angle. | ||
""" | ||
a2 = angle/2.0 | ||
c = cos(a2) | ||
s = sin(a2) | ||
return (axis_x * s, axis_y * s, axis_z * s, c) |
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.
nice, would be useful to have this in the addition to the existing Graphic.rotate
# X label | ||
self.ax.docks["bottom"].size = 30 | ||
self.ax.docks["bottom"].add_text( | ||
"X", | ||
font_size=16, | ||
face_color=(0, 0, 0, 1), | ||
anchor="middle-center", | ||
offset=(0, 0, 0), | ||
) | ||
self.ax.docks["bottom"].background_color = self.WHITE | ||
|
||
# Y label | ||
q = rotate(pi/2.0, 0., 0., 1.) # rotate 90 deg around z-axis | ||
self.ax.docks["left"].size = 30 | ||
self.ax.docks["left"].add_text( | ||
"Y", | ||
font_size=16, | ||
face_color=(0, 0, 0, 1), | ||
anchor="middle-center", | ||
offset=(0, 0, 0), | ||
rotation=q, | ||
) |
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.
pygfx will have seen soon, let's wait until we have the proper implementation pygfx/pygfx#739
self.ax.docks["top"].size = 30 | ||
self.ax.docks["top"].add_text( | ||
"Line Plots", | ||
font_size=16, | ||
face_color=(0, 0, 0, 1), | ||
anchor="middle-center", | ||
offset=(0, 0, 0), | ||
) | ||
self.ax.docks["top"].background_color = self.WHITE |
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.
why not subplot.title = "title"
?
Nice work! I was taking a look at your repos, are you trying to create something like this https://github.com/uutzinger/SerialUI ? Curious to hear how fastplotlib has been working for your use case. |
Yes that is why I am looking into fastplotlib. I hope to have some working prototype with fastplotlib shortly. I have been trying to figure out what the advantage of fastplotlib might be compared to pyqtgraph which is what I am currently using.
|
We rely on the community for more detailed Qt examples, thanks for your contribution! We're not a Qt lib like pyqtgraph, wgpu can render to a anything that rendercanvas supports.
How many lines are your plotting and how many points per line? Is your 3060 selected or integrated graphics?
I'm hoping to make a benchmark for fastplotlib soon, you can take a look at the pygfx benchmarks for now: https://github.com/pygfx/pygfx-benchmarks
I think the rendering is intentionally paused when the canvas is being resized. |
Test Programs3 x 50_000 line segments per frame Hardware Options
Running on Ubuntu FASTPLOTLIB PerformanceNividia 3060 VulkanLines/s: 10,215,192, Interval: 1.011 Generating: 4.1% FPS: 63.40 Python Main Thread usage: 60.3% fullscreenLines/s: 5,058,138, Interval: 1.048 Generating: 3.8% FPS: 31.27 Python Main Thread usage: 48.7% Radeon VulkanLines/s: 11,278,138, Interval: 1.007 Generating: 4.9% FPS: 75.57 Python Main Thread usage: 75.6% fullscreenLines/s: 5,571,927, Interval: 1.055 Generating: 3.0% FPS: 34.26 Python Main Thread usage: 49.8% CPU/LLVM VulkanLines/s: 350,917, Interval: 1.715 Generating: 0.3% FPS: 2.33 Python Main Thread usage: 4.1% fullscreenLines/s: 540,940, Interval: 1.112 Generating: 0.3% FPS: 3.39 Python Main Thread usage: 6.4% Radeon OpenGLLines/s: 14,919,069, Interval: 1.010 Generating: 6.4% FPS: 88.10 Python Main Thread usage: 86.6% fullscreenLines/s: 5,379,418, Interval: 1.041 Generating: 3.5% FPS: 32.88 Python Main Thread usage: 49.2% PYQTGRAPH Performanceregular windowLines/s: 6,333,290, Interval: 1.018 Generating: 2.3% FPS: 41.75 Python Main Thread usage: 82.8% full screenLines/s: 2,195,240, Interval: 1.033 Generating: 0.8% FPS: 14.54 Python Main Thread usage: 72.9% |
Thanks for the example, we're a bit busy with other projects at the moment so I'll incorporate your changes next month. |
Updated
legend.py
:Example
qt/lineplot.py
gitignore
testing
python docs/source/generate_api.py
because legend has now background color option