Hi,
I have a polygon that has a hole and try to plot it in plotly. I tried to use fill=“tonext”, but it didn’t work.
ext_x = [0.0, 0.0, 0.7292278554140239, 2.894754202276431, 6.430780618346944, 11.229866730289075, 17.146194735046095, 24.0, 31.583033120367872, 39.664887471987356, 48.0, 952.0, 960.3351125280127, 968.4169668796321, 976.0, 982.8538052649538, 988.770133269711, 993.569219381653, 997.1052457977236, 999.270772144586, 1000.0, 1000.0, 999.270772144586, 997.1052457977236, 993.569219381653, 988.770133269711, 982.8538052649538, 976.0, 968.4169668796321, 960.3351125280127, 952.0, 48.0, 35.576685835079005, 23.999999999999993, 19.029437251522857, 14.058874503045722, 6.430780618346944, 1.6355603381247192, 0.0]
ext_y = [48.0, 352.0, 360.33511252801264, 368.4169668796321, 376.0, 382.8538052649539, 388.7701332697109, 393.56921938165306, 397.1052457977236, 399.270772144586, 400.0, 400.0, 399.270772144586, 397.10524579772357, 393.56921938165306, 388.7701332697109, 382.8538052649539, 376.0, 368.4169668796321, 360.33511252801264, 352.0, 48.0, 39.6648874719873, 31.583033120367872, 24.0, 17.14619473504615, 11.229866730289018, 6.430780618346944, 2.894754202276431, 0.7292278554140239, 0.0, 0.0, 1.6355603381247192, 6.430780618346944, 10.244827560696333, 14.058874503045715, 23.999999999999993, 35.576685835079005, 48.0]
hole_x = [83.88225099390856, 951.3014249134637, 957.5461287600875, 962.9237412042767, 967.9694412996531, 972.5299180020672, 976.4666035346281, 979.659883699488, 982.0127322947158, 983.4536592063436, 984.0, 984.0, 983.4536592063436, 982.0127322947158, 979.659883699488, 976.4666035346282, 972.5299180020671, 967.9694412996535, 962.9237412042764, 957.5461287600876, 951.3014249134637, 48.69857508653619, 42.45387123991239, 37.07625879572353, 32.030558700346745, 27.470081997932727, 23.53339646537195, 20.340116300511887, 17.987267705284314, 16.546340793656313, 16.0, 16.0, 81.94112549695427, 93.25483399593904, 26.114122634336116, 20.40675346402863, 17.22373253280421, 16.138063369282445, 16.798042171024676, 17.223732532804213, 20.40675346402863, 25.47020854668355, 30.96922782831494, 32.06903168464122, 39.75352398612065, 48.00000000000001, 56.246476013879345, 63.93096831535876, 71.36895663027515, 138.50966799187808, 149.82337649086284, 83.88225099390856]
hole_y = [16.0, 16.0, 16.546340793656316, 17.987267705284363, 20.340116300511784, 23.53339646537195, 27.470081997932834, 32.03055870034654, 37.076258795723746, 42.453871239911955, 48.69857508653683, 351.30142491346317, 357.546128760088, 362.9237412042762, 367.9694412996536, 372.5299180020672, 376.4666035346282, 379.659883699488, 382.0127322947157, 383.4536592063437, 384.0, 384.0, 383.4536592063437, 382.01273229471576, 379.65988369948815, 376.46660353462806, 372.5299180020673, 367.9694412996533, 362.9237412042765, 357.5461287600875, 351.3014249134638, 83.88225099390856, 149.82337649086284, 138.50966799187808, 71.36895663027515, 63.93096831535876, 56.246476013879345, 48.00000000000001, 42.986963302355036, 39.75352398612065, 32.069031684641224, 25.47020854668357, 21.250662644471124, 20.406753464028633, 17.223732532804213, 16.138063369282445, 17.22373253280421, 20.40675346402863, 26.114122634336116, 93.25483399593904, 81.94112549695427, 16.0]
fig = go.Figure()
exterior = go.Scatter(x=ext_x, y=ext_y, fill="tonext")
hole = go.Scatter(x=hole_x, y=hole_y)
fig.add_traces(hole)
fig.add_traces(exterior)
fig.update_yaxes(scaleanchor="x", scaleratio=1)
fig.show()
If I changed the polygon to simple rectangular, it worked.
exterior = go.Scatter(x=[0,1000,1000,0,0], y=[0,0,400,400,0], fill="tonext")
hole = go.Scatter(x=hole_x, y=hole_y)
fig.add_traces(hole)
fig.add_traces(exterior)
fig.update_yaxes(scaleanchor="x", scaleratio=1)
fig.show()
I am confused as to why the first one didn’t work whereas the last one did work.