flatsurf / sage-flatsurf

Flat surfaces in Sage
https://flatsurf.github.io/sage-flatsurf/
GNU General Public License v2.0
10 stars 10 forks source link

Remove fill from plots #180

Closed sfreedman67 closed 1 year ago

sfreedman67 commented 2 years ago

It would be nice to make plots in sage-flatsurf that don't have fill:

s = fs.translation_surfaces.octagon_and_squares()
s.plot(fill=False)

Here is my current workaround:

def remove_fill_from_polygon(plt):
    for obj in plt._objects:
        if obj.parent() == sage.plot.polygon.Polygon:
            opts = obj._options
            opts['fill'] = False
            obj.set_options(opts)
    return plt
videlec commented 2 years ago

As you might have seen, the code of Polygon.plot at lines 942-951 of polygon.py is not very flexible

    def plot(self, translation=None):
        P = self.vertices(translation)
        return point2d(P, color='red') + line2d(P + (P[0],), color='orange') + polygon2d(P, alpha=0.3)

Ideally, all arguments of plot should be forwarded to either point2d, line2d or polygon2d functions. However, it is not clear what should be the design for the options. Maybe we should just follow sage Polyhedron with a point, line and polygon arguments.

fchapoton commented 1 year ago

Note that polygon2d by itself already draws the boundary, so that adding line2d is not necessary.

saraedum commented 1 year ago

Note that polygon2d by itself already draws the boundary, so that adding line2d is not necessary.

Probably the reason here was to only have "alpha" on the fill but not on the outline?

saraedum commented 1 year ago

@sfreedman67 this is actually supported:

s = flatsurf.translation_surfaces.octagon_and_squares()
g = s.graphical_surface()
g.polygon_options['fill'] = None
g.plot()

image

saraedum commented 1 year ago

@sfreedman67 please reopen if I missed something here.

saraedum commented 1 year ago

@sfreedman67 also note that https://github.com/flatsurf/sage-flatsurf/issues/109 will try to implement what you had proposed initially, namely S.plot(fill=None) to do the right thing.