I am trying to create a series of hatched square PNGs - similarly to the swatches shown here towards the end of the page.
These are not for use on the web - so I think using textures.js would be too much of a roundabout route, and I stumbled upon Plotly, and specifically this
I got as far as this
import plotly.express as px
import plotly.graph_objects as go
xy = [
[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]
]
fig = go.Figure(go.Scatter(x=[ co[0] for co in xy ], y=[ co[1] for co in xy ],
fill="toself", marker={'size': 0 }
))
fig.update_layout(showlegend=False)
fig.update_xaxes(visible=False)
fig.update_yaxes(visible=False)
img_bytes = fig.to_image(format="png")
fig.write_image("foo.png")
which generates this:

but I am struggling to NOT show the dots at the corners of the rectangle.
How do I do that? I know that a scatterplot without points is kind of nonsensical, so if there is a cleaner solution that's fine too.
(I suppose I will figure out how to NOT have lines and background and how to fill it with the hatch - but help is welcome on that too)
To plot without lines and without markers
fig = go.Figure(go.Scatter(x=[ co[0] for co in xy ], y=[ co[1] for co in xy ],
fill="toself", mode='text'
))
To plot without markers but with lines
fig = go.Figure(go.Scatter(x=[ co[0] for co in xy ], y=[ co[1] for co in xy ],
fill="toself", mode='lines'
))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With