geom_contour() fails with an unclear error when the input data is not ordered in a specific way. This happens even when the data forms a valid and complete grid.
Example:
df = pd.DataFrame({
'x': [0, 0, 1, 1],
'y': [0, 1, 0, 1],
'z': [0, 1, 2, 3],
})
ggplot(df) + geom_contour(aes('x', 'y', z='z')) + coord_fixed()
Output:
Data grid must be at least 2 columns wide (was 1)
Reordering the rows (e.g. by sorting) makes the plot work. For example:
ggplot(df.sort_values(by=["y", "x"])) + geom_contour(aes('x', 'y', z='z')) + coord_fixed()
