Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:
import matplotlib.pyplot as plt
import numpy as np
import pygimli as pg
import pygimli.meshtools as mt
from pygimli.physics import ert
world = mt.createWorld(start=(-100, -40), end=(100, 0))
iPos = (-49,-15) #Inyection Point
iPos2 = (50, -15) #Inyection Point 2
fault = mt.createPolygon([(-100, -40), (-100, -3), (-52, -5), iPos, (-40, -40)], isClosed= True)
layer = mt.createPolygon([iPos, iPos2, (100, -8)],
addNodes=100, interpolate='spline', isClosed=False)
world += layer
world += fault
world.addRegionMarker((40, -10), marker=1)
world.addRegionMarker((-75, -35), marker=2)
world.addRegionMarker((40, -35), marker=3)
pg.show(world, markers=True)
...
Expected behavior
To show the markers.
Actual behavior
Shows an error:
KeyError Traceback (most recent call last)
Cell In[136], [line 1](vscode-notebook-cell:?execution_count=136&line=1)
----> [1](vscode-notebook-cell:?execution_count=136&line=1) pg.show(world, markers=True)
File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146), in show(obj, data, **kwargs)
[143](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:143) n.pos()[1] = n.pos()[2]
[144](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:144) return showMesh(meshSwap, data, **kwargs)
--> [146](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146) return showMesh(mesh, data, **kwargs)
[147](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:147) elif mesh.dim() == 3:
[149](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:149) from .pv import showMesh3D
File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458), in showMesh(mesh, data, block, colorBar, label, coverage, ax, savefig, showMesh, showBoundary, markers, **kwargs)
[453](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:453) pg.viewer.mpl.drawSelectedMeshBoundaries(ax, b,
[454](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:454) color=(0.0, 0.0, 0.0, 1.0),
[455](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:455) linewidth=1.4)
[457](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:457) if kwargs.pop("boundaryMarkers", False):
--> [458](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458) pg.viewer.mpl.drawBoundaryMarkers(
[459](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:459) ax, mesh,
[460](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:460) clipBoundaryMarkers=kwargs.pop('clipBoundaryMarkers', False),
[461](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:461) **kwargs.pop('boundaryProps', {}))
[463](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:463) fitView = kwargs.pop('fitView', fitViewDefault)
[465](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:465) if fitView is not False:
File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542), in drawBoundaryMarkers(ax, mesh, clipBoundaryMarkers, **kwargs)
[540](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:540) for i, m in enumerate(ms):
[541](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:541) bs = mesh.findBoundaryByMarker(m)
--> [542](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542) paths = mesh.findPaths(bs)
[543](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:543) col = 'C' + str(i)
[545](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:545) for p in paths:
File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426), in __Mesh_findPaths__(self, bounds)
[424](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:424) # starting node
[425](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:425) path.append(rID)
--> [426](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426) followPath(path, S, rID)
[428](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:428) ## remaining are closed
[429](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:429) for i in range(S.shape[0]):
File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396), in __Mesh_findPaths__.<locals>.followPath(path, S, rID)
[393](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:393) # print('row', rID, 'col', cID)
[394](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:394) # print('add', cID)
[395](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:395) path.append(cID)
--> [396](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396) S.pop((rID, cID))
[397](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:397) S.pop((cID, rID))
[398](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:398) # print('pop-r', (rID, cID))
KeyError: (0, 207)
If possible, please add one or more labels to your issue, e.g. if you expect that your issue is rather a question than a problem with the code, please add the label "question".
Problem description
I'm getting an error when I do markers=True in pg.show()
Your environment
Please provide the output of
print(pygimli.Report())
here. If that does not work, please give provide some additional information on your:Steps to reproduce
Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:
Expected behavior
To show the markers.
Actual behavior
Shows an error: