emilk / egui_plot

2D plotting library in Rust for egui
Apache License 2.0
95 stars 31 forks source link

PlotImage Size not being applied? #56

Closed ntlively closed 2 days ago

ntlively commented 2 weeks ago

Describe the bug PlotImage is displayed correctly, but size parameter of new() does not scale the image appropriately.

To Reproduce Set size to a silly value (very small or very large) image

The image is not scaled appropriately, still renders the same. (image is a Gaussian blur, but not scaled, still "square"/original ratio) image

Expected behavior

Additional context

I've tried values between 0.0 and 1.0 to see if the size was a scaled/standardized ratio. Am I misunderstanding size for PlotImage, or is it not implemented the way I am assuming it to be? Vec2 usually represents width/height in my experience.

ntlively commented 2 days ago

Coming back to do my homework, this isn't a bug report, but just a misunderstanding with my code. Apologies if this all seems obvious, I'm doing this as my first rust project in order to learn. Hopefully it'll be a good breadcrumb trail for the next person.

In _eguiplot there is a plot_demo.rs -> ItemsDemo that uses the PlotImage similar to what I was trying to do in the OP. See below from the demo: image And the associated image in the demo: image

It very obviously works fine, and scales if you modify the size. Ex: image


ThReE HoUrS L8tEr It turns out there was never an issue with either my code or egui_plot features. I just didn't realize that the scale of the entire graph was changing in order to try and keep the image visually square.

Example applying the size inside the vec2 to just Y (you can scale it like the demo just fine, it just scales both x and y together): image

Notice the scale on the edges, its working fine. Just hard to notice if you're scaling by small numbers and/or the auto scaling makes it stay 'square'. Now to see if there is a way to disable the auto-scaling.

ntlively commented 2 days ago

Closing as I've answered my own question, thanks.

FYI you can disable auto axis scaling with auto_bounds: false.into() 🤓