Plots the room with its walls, microphones, sources and images
(
self,
img_order=None,
freq=None,
figsize=None,
no_axis=False,
mic_marker_size=10,
plot_directivity=True,
ax=None,
plot_walls=True,
**kwargs,
)
| 1462 | self._init_room_engine() |
| 1463 | |
| 1464 | def plot( |
| 1465 | self, |
| 1466 | img_order=None, |
| 1467 | freq=None, |
| 1468 | figsize=None, |
| 1469 | no_axis=False, |
| 1470 | mic_marker_size=10, |
| 1471 | plot_directivity=True, |
| 1472 | ax=None, |
| 1473 | plot_walls=True, |
| 1474 | **kwargs, |
| 1475 | ): |
| 1476 | """Plots the room with its walls, microphones, sources and images""" |
| 1477 | |
| 1478 | try: |
| 1479 | import matplotlib |
| 1480 | import matplotlib.pyplot as plt |
| 1481 | from matplotlib.collections import PatchCollection |
| 1482 | from matplotlib.patches import Polygon |
| 1483 | except ImportError: |
| 1484 | import warnings |
| 1485 | |
| 1486 | warnings.warn("Matplotlib is required for plotting") |
| 1487 | return |
| 1488 | |
| 1489 | fig = None |
| 1490 | |
| 1491 | if self.dim == 2: |
| 1492 | fig = plt.figure(figsize=figsize) |
| 1493 | |
| 1494 | if no_axis is True: |
| 1495 | if ax is None: |
| 1496 | ax = fig.add_axes([0, 0, 1, 1], aspect="equal", **kwargs) |
| 1497 | ax.axis("off") |
| 1498 | rect = fig.patch |
| 1499 | rect.set_facecolor("gray") |
| 1500 | rect.set_alpha(0.15) |
| 1501 | else: |
| 1502 | if ax is None: |
| 1503 | ax = fig.add_subplot(111, aspect="equal", **kwargs) |
| 1504 | |
| 1505 | # draw room |
| 1506 | if plot_walls: |
| 1507 | corners = np.array([wall.corners[:, 0] for wall in self.walls]).T |
| 1508 | polygons = [Polygon(xy=corners.T, closed=True)] |
| 1509 | p = PatchCollection( |
| 1510 | polygons, |
| 1511 | cmap=matplotlib.cm.jet, |
| 1512 | facecolor=np.array([1, 1, 1]), |
| 1513 | edgecolor=np.array([0, 0, 0]), |
| 1514 | ) |
| 1515 | ax.add_collection(p) |
| 1516 | |
| 1517 | if self.mic_array is not None: |
| 1518 | for i in range(self.mic_array.nmic): |
| 1519 | ax.scatter( |
| 1520 | self.mic_array.R[0][i], |
| 1521 | self.mic_array.R[1][i], |