gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:
https://www.pygimli.org
Other
364 stars 133 forks source link

CellBrowse shows an infobox for at all axes in a subplot at once. #111

Closed carsten-forty2 closed 2 years ago

carsten-forty2 commented 6 years ago
import numpy as np
import pygimli as pg
from pygimli.mplviewer import CellBrowser, drawModel

axs = pg.plt.subplots(1, 2)[1]

x = np.linspace(0,10,11)
m1 = pg.createGrid(x, x)
pg.show(m1, np.arange(m1.cellCount()), ax=axs[0])
pg.show(m1, np.arange(m1.cellCount())[::-1], ax=axs[1])
pg.wait()

When I click on a cell in axs[0] an infobox appears in axs[0] and axs[1]. However both data values in the box are correct for both axes.

2nd related problem:

While mixing subplots with cell and node data .. the cell browser raise an unhandled exception when pressing a key.

halbmy commented 2 years ago

I just checked this very old issue again. Seems like you can only activate the CellBrowser with the show command by block=True but only for the second call:

import numpy as np
import pygimli as pg
from pygimli.viewer.mpl import CellBrowser

axs = pg.plt.subplots(1, 2)[1]

x = np.linspace(0, 10, 11)
mesh = pg.createGrid(x, x)
data = np.arange(mesh.cellCount())
pg.show(mesh, data, ax=axs[0])
pg.show(mesh, data[::-1], ax=axs[1], block=True)
pg.wait()

Then the cell browser only targets to the second subplot not matter which you click in.

If you connect the CellBrowser manually

pg.show(mesh, data, ax=axs[0])
CellBrowser(mesh, data, ax=axs[0])
pg.show(mesh, data[::-1], ax=axs[1])
CellBrowser(mesh, data[::-1], ax=axs[1])

the cellbrowser targets to both subplots, no matter which one you click in.

Not clear whether it can be solved easily or whether it is of importance anyway.

halbmy commented 2 years ago

I guess there won't be any solution to this issue. The Cell browser only works well on a single axis figure.

Closing the issue on its four-year anniversary.