Skip to content
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

Renamed the _data_to_plot attribute variable. #3635

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions bluemira/display/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __init__(
# discretisation points representing the shape in global coordinate system
self.data = []
# modified discretisation points for plotting (e.g. view transformation)
self._data_to_plot = []
self._projected_data = []

def set_view(self, view: str | BluemiraPlacement):
"""Set the plotting view"""
Expand Down Expand Up @@ -314,14 +314,14 @@ def _populate_data(
):
"""
Internal function that makes the plot. It fills self._data and
self._data_to_plot
self._projected_data
"""

@abstractmethod
def _make_plot_2d(self):
"""
Internal function that makes the plot. It should use self._data and
self._data_to_plot, so _populate_data should be called before.
self._projected_data, so _populate_data should be called before.
"""

def _set_aspect_2d(self):
Expand Down Expand Up @@ -392,7 +392,7 @@ def initialise_plot_3d(self, ax=None):
@abstractmethod
def _make_plot_3d(self):
"""Internal function that makes the plot. It should use self._data and
self._data_to_plot, so _populate_data should be called before.
self._projected_data, so _populate_data should be called before.
"""

def plot_3d(
Expand All @@ -411,9 +411,7 @@ def plot_3d(
self.initialise_plot_3d(ax=ax)
# this function can be common to 2D and 3D plot
# self._data is used for 3D plot
# self._data_to_plot is used for 2D plot
# TODO: probably better to rename self._data_to_plot into
# self._projected_data or self._data2d
# self._projected_data is used for 2D plot
self._populate_data(obj)
self._make_plot_3d()
self._set_aspect_3d()
Expand Down Expand Up @@ -445,14 +443,14 @@ def _populate_data(self, obj: npt.ArrayLike):
points = _parse_to_xyz_array(obj).T
self._data = points
# apply rotation matrix given by options['view']
self._data_to_plot = np.dot(
self._projected_data = np.dot(
np.c_[self._data, np.ones(len(self._data))],
self.options.view_placement.to_matrix().T,
).T[0:2]

def _make_plot_2d(self):
if self.options.show_points:
self.ax.scatter(*self._data_to_plot, **self.options.point_options)
self.ax.scatter(*self._projected_data, **self.options.point_options)
self._set_aspect_2d()

def _make_plot_3d(self, *args, **kwargs): # noqa: ARG002
Expand Down Expand Up @@ -486,11 +484,11 @@ def _populate_data(self, obj: BluemiraWire):
).T
self._pplotter = PointsPlotter(self.options, data=pointsw)
self._data = pointsw
self._data_to_plot = self._pplotter._data_to_plot
self._projected_data = self._pplotter._projected_data

def _make_plot_2d(self):
if self.options.show_wires:
self.ax.plot(*self._data_to_plot, **self.options.wire_options)
self.ax.plot(*self._projected_data, **self.options.wire_options)

if self.options.show_points:
self._pplotter._ax = self.ax
Expand Down Expand Up @@ -535,24 +533,24 @@ def _populate_data(self, obj: BluemiraFace):
self._wplotters.append(wplotter)
self._data = np.array(self._data)

self._data_to_plot = [[], []]
self._projected_data = [[], []]
for w in self._wplotters:
self._data_to_plot[0] += [*w._data_to_plot[0].tolist(), None]
self._data_to_plot[1] += [*w._data_to_plot[1].tolist(), None]
self._projected_data[0] += [*w._projected_data[0].tolist(), None]
self._projected_data[1] += [*w._projected_data[1].tolist(), None]

def _make_plot_2d(self):
if self.options.show_faces:
face_opts = self.options.face_options
if face_opts.get("hatch", None) is not None:
self.ax.add_patch(
Polygon(
np.asarray(self._data_to_plot).T,
np.asarray(self._projected_data).T,
fill=False,
**face_opts,
)
)
else:
self.ax.fill(*self._data_to_plot, **face_opts)
self.ax.fill(*self._projected_data, **face_opts)

for plotter in self._wplotters:
plotter._ax = self.ax
Expand Down Expand Up @@ -620,7 +618,7 @@ def _make_plot_2d(self):
def _make_plot_3d(self):
"""
Internal function that makes the plot. It should use self._data and
self._data_to_plot, so _populate_data should be called before.
self._projected_data, so _populate_data should be called before.
"""
for plotter in self._cplotters:
plotter._ax = self.ax
Expand Down
Loading