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

Improved surface plots #329

Open
videlec opened this issue Dec 31, 2024 · 0 comments · May be fixed by #330
Open

Improved surface plots #329

videlec opened this issue Dec 31, 2024 · 0 comments · May be fixed by #330

Comments

@videlec
Copy link
Collaborator

videlec commented Dec 31, 2024

This issue proposes to rewrite most of the GraphicalSurface in order to simplify it and also make it more flexible. In particular, we get rid of the GraphicalPolygon class. We propose to rename it SurfacePlot (in order to follow name conventions in sage, eg GraphPlot). The basic structure we propose is as follows.

class SurfacePlot:
    def visible_labels(self):
        r"""
        Iterable of labels of polygons to be displayed
        """
        # go through internal attributes and figure out what to do

    def polygon_layout(self, label):
        r"""
        Return ``None`` when the polygon with the given ``label`` is invisible
        or the similarity used to render it
        """
        # go through internal attributes and figure out what to do

    def polygon_options(self, label):
        r"""
        Return ``None`` when the polygon should not be plotted or a dictionary of options.

       If not ``None``, the dictionary in the output has a key ``"points"`` which is the list of
       positions of the vertices to be rendered (which is the required argument of the sage
       ``polygon2d`` function).
        """
        # go through internal attributes and figure out what to do

    def polygon_label_options(self, label):
        r"""
        Return ``None`` when the polygon label should not be plotted or a dictionary of options

        If not ``None``, the dictionary in the output always has a key ``"string"`` and a key ``"xy"``
        which are the string label and position to be rendered (which are the required
        arguments of the sage ``text`` function).
        """
        # go through internal attributes and figure out what to do

    def edge_options(self, label, edge):
        r"""
        Return ``None`` when the edge should not be plotted or a dictionary of options

        If not ``None``, the dictionary in the output has a key ``"points"`` which is the 2-tuple of
        start and end to be rendered (which is the required argument of the sage ``line2d``
        function).
        """
        # go through internal attributes and figure out what to do

    def edge_label_options(self, label, edge):
        r"""
        Return ``None`` when the edge label should not be plotted or a dictionary of options

        If not ``None``, the dictionary in the output has a key ``"string"`` and a key ``"xy"``
        which are the string label and position to be rendered (which are the required
        arguments of the sage ``text`` function).
        """
        # go through internal attributes and figure out what to do

    def plot(self):
        G = Graphics()

        for label in self.visible_polygons():
            opts = self.polygon_options(label)
            if opts is not None:
                G += polygon2d(**opts)
                opts = self.polygon_label_options(label)
                if opts is not None:
                    G += text2d(**opts)

            for edge in range(len(self._ss.polygon(label).vertices())):
                opts = self.edge_options(label, edge)
                if opts is not None:
                    G += line2d(**opts)
                    opts = self.edge_label_options(label)
                    if opts is not None:
                        G += text2d(**opts)

        return G

The main piece of code of a SurfacePlot would be to generate the visible labels and the similarities to be returned in polygon_layout. For infinite surface, these ought to be dynamical (eg via a make_visible or explore_more or ...).

Typically, one wants to plot additional features on a rendered surface. This could be handled with the access to SurfacePlot.visible_labels() and SurfacePlot.polygon_layout(label).

@videlec videlec linked a pull request Jan 1, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant