MCPcopy
hub / github.com/LCAV/pyroomacoustics / plot

Method plot

pyroomacoustics/room.py:1464–1758  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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],

Callers 15

highpassFunction · 0.45
time_dBFunction · 0.45
compare_plotFunction · 0.45
real_spectrumFunction · 0.45
plot_funcMethod · 0.45
plotMethod · 0.45
test_build_rir.pyFile · 0.45
test_resample.pyFile · 0.45
test_anechoic_roomFunction · 0.45

Calls 3

get_bboxMethod · 0.95
plot_responseMethod · 0.80
responseMethod · 0.80

Tested by 9

test_anechoic_roomFunction · 0.36
test_room_2dMethod · 0.36
test_room_3dMethod · 0.36
test_plot_walls_2dMethod · 0.36
test_plot_walls_3dMethod · 0.36
test_sofa_one_sideFunction · 0.36
test_sofa_two_sidesFunction · 0.36
test_sofa_and_cardioidFunction · 0.36