-
Notifications
You must be signed in to change notification settings - Fork 55
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
wrapping of implot BeginSubplots appears to have wrong argument type for row_ratios
and col_ratios
#207
Comments
Hello Anthony, As you can see from the number of commits, this one was a bit complex, since I had to write a custom function for the Python bindings and made it so that it is correctly renamed when used from Python. Anyhow, the signature is now: def begin_subplots(
title_id: str,
rows: int,
cols: int,
size: ImVec2,
flags: SubplotFlags = 0,
row_ratios: List[float] = List[float](),
col_ratios: List[float] = List[float](),
) -> bool:
pass The CI is ongoing and you will be able to download the wheels from here: https://github.com/pthom/imgui_bundle/actions/runs/8795293678 (They should be ready in 2 hours)
No, this was a new error in the bindings when the values were interpreted as modifiable. |
Pascal, This almost seems perfect, thank you so much for working on this and sorry it was such a challenge. I built it from source on my apple silicon system. The only remaining bug I see is that the input lists for the row and column ratios are not updated back to python. I believe they should update to return the current ratios if the user interacts with the plots. Below is a sample script that demonstrates what I am observing. # Demo of issue that you can't adjust and get back subplot layout ratios
import numpy as np
from imgui_bundle import imgui, immapp, implot
from loguru import logger as log
x = np.log(np.arange(100))
y = np.sin(x)
y2 = y+1
row_ratios = [.6, .4]
col_ratios = [.75, .25]
scater_values = np.array([x,y2]).transpose()
log.warning(f"{scater_values.shape=}")
def gui():
"Our gui function, which will be invoked by the application loop"
if implot.begin_subplots("Subplots - try and adjust plot sizes", rows=2, cols=2, size=imgui.ImVec2(-1,-1),
row_ratios=row_ratios,
col_ratios=col_ratios):
for i in range(4):
if implot.begin_plot(f"Play with me {i}"):
implot.plot_line("line plot", x, y2)
implot.plot_scatter("scatter plot", x, y)
implot.end_plot()
implot.end_subplots()
# Ratios do not seem to be updated
print(row_ratios, col_ratios)
immapp.run(gui, with_implot=True) |
Hello Anthony, You're right, I had not suspected that those could be modified. b9ce2af#diff-512319a401e7062ec1af5cc784145a9b96f1f0d871406cb908ac97a9008f9052 Thanks for the minimal reproducible demo, it saves a lot of time. Here is its updated version: import numpy as np
from imgui_bundle import imgui, immapp, implot
x = np.log(np.arange(100))
y = np.sin(x)
y2 = y+1
scater_values = np.array([x,y2]).transpose()
ratios = implot.SubplotsRowColRatios() # SubplotsRowColRatios is a new type, specialized for this
ratios.row_ratios = [.6, .4]
ratios.col_ratios = [.75, .25]
def gui():
"Our gui function, which will be invoked by the application loop"
if implot.begin_subplots("Subplots - try and adjust plot sizes", rows=2, cols=2, size=imgui.ImVec2(-1,-1),
row_col_ratios=ratios):
for i in range(4):
if implot.begin_plot(f"Play with me {i}"):
implot.plot_line("line plot", x, y2)
implot.plot_scatter("scatter plot", x, y)
implot.end_plot()
implot.end_subplots()
immapp.run(gui, with_implot=True) |
And wheels are being built here: https://github.com/pthom/imgui_bundle/actions/runs/8834742423 You should be able to download them in one hour. |
I noticed what might be a bug on the wrapping of the
BeginSubplots
function:From implot.h:
In the python wrapping, it appears to want a float for both the
row_ratios
and thecol_ratios
instead of taking a list of floats for each (of length rows and cols). It should also return list of floats as well.Here is the python type definition:
The text was updated successfully, but these errors were encountered: