I got a function plotting figures with constrained axis. Sometimes, the entry data is an empty dataframe and the expected output is an empty graph showing the empty grid (and respecting the constrained axis specification).
Unfortunately, the output I got is a “crushed on itself” graph, as shown under.
This is what I am looking for:
Does someone have an idea to get the desired output without altering my code too much?
Here is my code:
from pandas import DataFrame from plotly import graph_objs as go X = [0, 5, 10] Y = [0, 5, 10] df = DataFrame(index = X, columns = Y) fig = go.Figure() trace = go.Contour(x = X, y = Y, z = df) fig.add_trace(trace) fig.update_layout(xaxis = dict(constrain='domain'), yaxis = dict(constrain='domain', scaleanchor='x')) fig.show(renderer='png')